Fix crash on missing namespace name in namespace alias definition -- PR14085.
authorNico Weber <nicolasweber@gmx.de>
Sat, 27 Oct 2012 23:44:27 +0000 (23:44 +0000)
committerNico Weber <nicolasweber@gmx.de>
Sat, 27 Oct 2012 23:44:27 +0000 (23:44 +0000)
Patch from Brian Brooks <brooks.brian@gmail.com>!

llvm-svn: 166893

clang/lib/Parse/ParseDeclCXX.cpp
clang/test/Parser/namespaces.cpp

index 492250da1d49ac7df8337e5487489963de41cd6d..4cb14e24f48fc722106cf65f707d12557539ad40 100644 (file)
@@ -88,6 +88,12 @@ Decl *Parser::ParseNamespace(unsigned Context,
   }
 
   if (Tok.is(tok::equal)) {
+    if (Ident == 0) {
+      Diag(Tok, diag::err_expected_ident);
+      // Skip to end of the definition and eat the ';'.
+      SkipUntil(tok::semi);
+      return 0;
+    }
     if (!attrs.empty())
       Diag(attrTok, diag::err_unexpected_namespace_attributes_alias);
     if (InlineLoc.isValid())
index b8c7819a019f3399a0475e77a185d4c6c11936e6..6491cfd446b311ba15e956a1d8d42f266cb662eb 100644 (file)
@@ -6,3 +6,7 @@ namespace g { enum { o = 0 }; }
 void foo() {
   namespace a { typedef g::o o; } // expected-error{{namespaces can only be defined in global or namespace scope}}
 }
+
+// PR14085
+namespace PR14085 {}
+namespace = PR14085; // expected-error {{expected identifier}}