]> granicus.if.org Git - clang/commitdiff
Patch to fix a crash on incomplete class declaration.
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 14 May 2010 21:35:02 +0000 (21:35 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 14 May 2010 21:35:02 +0000 (21:35 +0000)
Radar 7923673.

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

lib/Sema/SemaDecl.cpp
test/Parser/cxx-undeclared-identifier.cpp [new file with mode: 0644]

index 76334e9a1258afebaf58f16d48a4d885815a38a5..5bb0b524d15800fe5b2c7ecd42d08839fd7059c9 100644 (file)
@@ -5329,9 +5329,13 @@ CreateNewDecl:
 
   // Maybe add qualifier info.
   if (SS.isNotEmpty()) {
-    NestedNameSpecifier *NNS
-      = static_cast<NestedNameSpecifier*>(SS.getScopeRep());
-    New->setQualifierInfo(NNS, SS.getRange());
+    if (SS.isSet()) {
+      NestedNameSpecifier *NNS
+        = static_cast<NestedNameSpecifier*>(SS.getScopeRep());
+      New->setQualifierInfo(NNS, SS.getRange());
+    }
+    else
+      Invalid = true;
   }
 
   if (Kind != TTK_Enum) {
diff --git a/test/Parser/cxx-undeclared-identifier.cpp b/test/Parser/cxx-undeclared-identifier.cpp
new file mode 100644 (file)
index 0000000..36d8f7a
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+class Foo::Bar { // expected-error {{use of undeclared identifier 'Foo'}} \
+                 // expected-note {{to match this '{'}} \
+                 // expected-error {{expected ';' after class}}
+                 // expected-error {{expected '}'}}