From: Nico Weber Date: Sat, 27 Oct 2012 23:44:27 +0000 (+0000) Subject: Fix crash on missing namespace name in namespace alias definition -- PR14085. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1bb329744ec98ca921bfc4f0888cff7ab4d1bf4;p=clang Fix crash on missing namespace name in namespace alias definition -- PR14085. Patch from Brian Brooks ! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166893 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 492250da1d..4cb14e24f4 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -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()) diff --git a/test/Parser/namespaces.cpp b/test/Parser/namespaces.cpp index b8c7819a01..6491cfd446 100644 --- a/test/Parser/namespaces.cpp +++ b/test/Parser/namespaces.cpp @@ -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}}