]> granicus.if.org Git - clang/commitdiff
Don't crash when forming a destructor name on an incomplete type.
authorJohn McCall <rjmccall@apple.com>
Sun, 11 Jun 2017 20:33:00 +0000 (20:33 +0000)
committerJohn McCall <rjmccall@apple.com>
Sun, 11 Jun 2017 20:33:00 +0000 (20:33 +0000)
Fixes PR25156.

Patch by Don Hinton!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305169 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaCXX/nested-name-spec.cpp

index 00a4b39f14236c3098232e3305e17218f10ec923..a9ff21bc41ab91c9aa0171ea4706c70f9ef08a8c 100644 (file)
@@ -189,12 +189,15 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc,
     // have one) and, if that fails to find a match, in the scope (if
     // we're allowed to look there).
     Found.clear();
-    if (Step == 0 && LookupCtx)
+    if (Step == 0 && LookupCtx) {
+      if (RequireCompleteDeclContext(SS, LookupCtx))
+        return nullptr;
       LookupQualifiedName(Found, LookupCtx);
-    else if (Step == 1 && LookInScope && S)
+    } else if (Step == 1 && LookInScope && S) {
       LookupName(Found, S);
-    else
+    } else {
       continue;
+    }
 
     // FIXME: Should we be suppressing ambiguities here?
     if (Found.isAmbiguous())
index 6ae45ff63332ea4c6078e42566671bdd8b3b1330..725ac64cedb7c5b60d9222b6f238739f9ae89b4b 100644 (file)
@@ -169,6 +169,13 @@ void N::f() { } // okay
 struct Y;  // expected-note{{forward declaration of 'Y'}}
 Y::foo y; // expected-error{{incomplete type 'Y' named in nested name specifier}}
 
+namespace PR25156 {
+struct Y;  // expected-note{{forward declaration of 'PR25156::Y'}}
+void foo() {
+  Y::~Y(); // expected-error{{incomplete type 'PR25156::Y' named in nested name specifier}}
+}
+}
+
 X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}}
 
 struct foo_S {