diff options
author | Nico Weber <nicolasweber@gmx.de> | 2015-02-15 07:26:13 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2015-02-15 07:26:13 +0000 |
commit | cfaa4cdc35c0b21fb6cef140615007f5782ae127 (patch) | |
tree | a1199cabf627be614528af619a2ffc8716aa76a5 /clang/test | |
parent | 78c424dfca9ac7b8ffb94d066771c23295d53427 (diff) | |
download | bcm5719-llvm-cfaa4cdc35c0b21fb6cef140615007f5782ae127.tar.gz bcm5719-llvm-cfaa4cdc35c0b21fb6cef140615007f5782ae127.zip |
Don't crash on `struct ::, struct ::` (and the same for enums).
The first part of that line doesn't parse correctly and ParseClassSpecifier() for
some reason skips to tok::comma to recover, and then
ParseDeclarationSpecifiers() sees the next struct and calls
ParseClassSpecifier() again with the same DeclSpec object.
However, the first call already called ActOnCXXGlobalScopeSpecifier() on the
DeclSpec's CXXScopeSpec, and sema gets confused when this gets called again.
As a fix, let ParseClassSpecifier() (and ParseEnumSpecifier()) call
ParseOptionalCXXScopeSpec() with a temporary CXXScopeSpec object, and only
copy it into the DeclSpec if things work out. (This is also how all the other
functions that set the DeclSpec's TypeSpecScope set it.)
Found by SLi's bot.
llvm-svn: 229288
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Parser/recovery.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/test/Parser/recovery.cpp b/clang/test/Parser/recovery.cpp index e53a361dca8..bca9ace89e2 100644 --- a/clang/test/Parser/recovery.cpp +++ b/clang/test/Parser/recovery.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s +// RUN: %clang_cc1 -verify -std=c++11 -fms-extensions %s 8gi///===--- recovery.cpp ---===// // expected-error {{unqualified-id}} namespace Std { // expected-note {{here}} @@ -202,3 +202,11 @@ namespace pr15133 { struct S2 :: S3 :: public S2 { // expected-error{{'public' cannot be a part of nested name specifier; did you mean ':'?}} }; } + +namespace InvalidEmptyNames { +// These shouldn't crash, the diagnostics aren't important. +struct ::, struct ::; // expected-error 2 {{expected identifier}} expected-error 2 {{declaration of anonymous struct must be a definition}} expected-warning {{declaration does not declare anything}} +enum ::, enum ::; // expected-error 2 {{expected identifier}} expected-warning {{declaration does not declare anything}} +struct ::__super, struct ::__super; // expected-error 2 {{expected identifier}} expected-error 2 {{expected '::' after '__super'}} +struct ::template foo, struct ::template bar; // expected-error 2 {{expected identifier}} expected-error 2 {{declaration of anonymous struct must be a definition}} expected-warning {{declaration does not declare anything}} +} |