hintonda created this revision.
hintonda added reviewers: doug.gregor, majnemer.
hintonda added a subscriber: cfe-commits.

Fix crash from PR25156 where getDestructorName() calls LookupQualifiedName() on 
incomplete type.

http://reviews.llvm.org/D17143

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/pr25156-crash-on-invalid.cpp

Index: test/SemaCXX/pr25156-crash-on-invalid.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/pr25156-crash-on-invalid.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Don't crash (PR25156).
+
+class foo; // expected-note {{forward declaration of 'foo'}}
+void f() {
+  foo::~foo(); // expected-error {{incomplete type 'foo' named in nested name 
specifier}}
+}
Index: lib/Sema/SemaExprCXX.cpp
===================================================================
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -189,9 +189,10 @@
     // 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)
-      LookupQualifiedName(Found, LookupCtx);
-    else if (Step == 1 && LookInScope && S)
+    if (Step == 0 && LookupCtx) {
+      if (!RequireCompleteDeclContext(SS, LookupCtx))
+        LookupQualifiedName(Found, LookupCtx);
+    } else if (Step == 1 && LookInScope && S)
       LookupName(Found, S);
     else
       continue;


Index: test/SemaCXX/pr25156-crash-on-invalid.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/pr25156-crash-on-invalid.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Don't crash (PR25156).
+
+class foo; // expected-note {{forward declaration of 'foo'}}
+void f() {
+  foo::~foo(); // expected-error {{incomplete type 'foo' named in nested name specifier}}
+}
Index: lib/Sema/SemaExprCXX.cpp
===================================================================
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -189,9 +189,10 @@
     // 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)
-      LookupQualifiedName(Found, LookupCtx);
-    else if (Step == 1 && LookInScope && S)
+    if (Step == 0 && LookupCtx) {
+      if (!RequireCompleteDeclContext(SS, LookupCtx))
+        LookupQualifiedName(Found, LookupCtx);
+    } else if (Step == 1 && LookInScope && S)
       LookupName(Found, S);
     else
       continue;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to