summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp18
-rw-r--r--clang/test/Modules/Inputs/cxx17/decls.h3
-rw-r--r--clang/test/Modules/Inputs/cxx17/module.modulemap1
-rw-r--r--clang/test/Modules/cxx17.cpp11
4 files changed, 31 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 719b6ad3414..d33a4759278 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2758,9 +2758,23 @@ static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
CtorY->getInheritedConstructor().getConstructor()))
return false;
}
+ ASTContext &C = FuncX->getASTContext();
+ if (!C.hasSameType(FuncX->getType(), FuncY->getType())) {
+ // We can get functions with different types on the redecl chain in C++17
+ // if they have differing exception specifications and at least one of
+ // the excpetion specs is unresolved.
+ // FIXME: Do we need to check for C++14 deduced return types here too?
+ auto *XFPT = FuncX->getType()->getAs<FunctionProtoType>();
+ auto *YFPT = FuncY->getType()->getAs<FunctionProtoType>();
+ if (C.getLangOpts().CPlusPlus1z && XFPT && YFPT &&
+ (isUnresolvedExceptionSpec(XFPT->getExceptionSpecType()) ||
+ isUnresolvedExceptionSpec(YFPT->getExceptionSpecType())) &&
+ C.hasSameFunctionTypeIgnoringExceptionSpec(FuncX->getType(),
+ FuncY->getType()))
+ return true;
+ return false;
+ }
return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
- FuncX->getASTContext().hasSameType(FuncX->getType(),
- FuncY->getType()) &&
hasSameOverloadableAttrs(FuncX, FuncY);
}
diff --git a/clang/test/Modules/Inputs/cxx17/decls.h b/clang/test/Modules/Inputs/cxx17/decls.h
new file mode 100644
index 00000000000..473b6d15112
--- /dev/null
+++ b/clang/test/Modules/Inputs/cxx17/decls.h
@@ -0,0 +1,3 @@
+struct MergeExceptionSpec {
+ ~MergeExceptionSpec(); // unevaluated exception spec
+};
diff --git a/clang/test/Modules/Inputs/cxx17/module.modulemap b/clang/test/Modules/Inputs/cxx17/module.modulemap
new file mode 100644
index 00000000000..2339e49e03b
--- /dev/null
+++ b/clang/test/Modules/Inputs/cxx17/module.modulemap
@@ -0,0 +1 @@
+module Decls { header "decls.h" }
diff --git a/clang/test/Modules/cxx17.cpp b/clang/test/Modules/cxx17.cpp
new file mode 100644
index 00000000000..1efb490828d
--- /dev/null
+++ b/clang/test/Modules/cxx17.cpp
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x c++ -std=c++1z -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/cxx17 %s -verify -fno-modules-error-recovery
+
+// expected-no-diagnostics
+struct MergeExceptionSpec {
+ ~MergeExceptionSpec();
+} mergeExceptionSpec; // trigger evaluation of exception spec
+
+#include "decls.h"
+
+MergeExceptionSpec mergeExceptionSpec2;
OpenPOWER on IntegriCloud