diff options
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 14 | ||||
-rw-r--r-- | clang/test/SemaCXX/cxx11-crashes.cpp | 12 |
2 files changed, 22 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 56f4019..dfdd367 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -4221,9 +4221,12 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, // A template constructor is never a copy constructor. // FIXME: However, it may actually be selected at the actual overload // resolution point. - if (isa<FunctionTemplateDecl>(ND)) + if (isa<FunctionTemplateDecl>(ND->getUnderlyingDecl())) continue; - const CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(ND); + // UsingDecl itself is not a constructor + if (isa<UsingDecl>(ND)) + continue; + auto *Constructor = cast<CXXConstructorDecl>(ND->getUnderlyingDecl()); if (Constructor->isCopyConstructor(FoundTQs)) { FoundConstructor = true; const FunctionProtoType *CPT @@ -4257,9 +4260,12 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, bool FoundConstructor = false; for (const auto *ND : Self.LookupConstructors(RD)) { // FIXME: In C++0x, a constructor template can be a default constructor. - if (isa<FunctionTemplateDecl>(ND)) + if (isa<FunctionTemplateDecl>(ND->getUnderlyingDecl())) + continue; + // UsingDecl itself is not a constructor + if (isa<UsingDecl>(ND)) continue; - const CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(ND); + auto *Constructor = cast<CXXConstructorDecl>(ND->getUnderlyingDecl()); if (Constructor->isDefaultConstructor()) { FoundConstructor = true; const FunctionProtoType *CPT diff --git a/clang/test/SemaCXX/cxx11-crashes.cpp b/clang/test/SemaCXX/cxx11-crashes.cpp index 97c95945..7c455ee 100644 --- a/clang/test/SemaCXX/cxx11-crashes.cpp +++ b/clang/test/SemaCXX/cxx11-crashes.cpp @@ -91,3 +91,15 @@ void test(int some_number) { // expected-note {{'some_number' declared here}} Foo(lambda); } } + +namespace pr29091 { + struct X{ X(const X &x); }; + struct Y: X { using X::X; }; + bool foo() { return __has_nothrow_constructor(Y); } + bool bar() { return __has_nothrow_copy(Y); } + + struct A { template <typename T> A(); }; + struct B : A { using A::A; }; + bool baz() { return __has_nothrow_constructor(B); } + bool qux() { return __has_nothrow_copy(B); } +} |