diff options
author | Nico Weber <nicolasweber@gmx.de> | 2012-10-27 23:44:27 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2012-10-27 23:44:27 +0000 |
commit | 729f1e2a1c27a13733cef967b180d006b59fe657 (patch) | |
tree | b504b62e1b305688f160608a05879c69f6780306 /clang | |
parent | 0c58ce9346e9a6366bd57f4531b267bda68ac6b0 (diff) | |
download | bcm5719-llvm-729f1e2a1c27a13733cef967b180d006b59fe657.tar.gz bcm5719-llvm-729f1e2a1c27a13733cef967b180d006b59fe657.zip |
Fix crash on missing namespace name in namespace alias definition -- PR14085.
Patch from Brian Brooks <brooks.brian@gmail.com>!
llvm-svn: 166893
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 6 | ||||
-rw-r--r-- | clang/test/Parser/namespaces.cpp | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 492250da1d4..4cb14e24f48 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/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/clang/test/Parser/namespaces.cpp b/clang/test/Parser/namespaces.cpp index b8c7819a019..6491cfd446b 100644 --- a/clang/test/Parser/namespaces.cpp +++ b/clang/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}} |