diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-01-13 02:24:58 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-01-13 02:24:58 +0000 |
commit | b1c217e4922589dcdd01a53ecbe1710ae4fb64cd (patch) | |
tree | 5c92e4a2f60a0be0330d806d9c16de1fcb5e5c53 | |
parent | 5dc76a5d34a1054bae2fd5bf6a9b8e44e2daecee (diff) | |
download | bcm5719-llvm-b1c217e4922589dcdd01a53ecbe1710ae4fb64cd.tar.gz bcm5719-llvm-b1c217e4922589dcdd01a53ecbe1710ae4fb64cd.zip |
If we don't find a matching ) for a ( in an exception specification, keep the tokens around so we can diagnose an error rather than silently discarding them.
llvm-svn: 225755
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 13 | ||||
-rw-r--r-- | clang/test/Parser/cxx-class.cpp | 8 |
2 files changed, 12 insertions, 9 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 09239f467ea..062b63e7fda 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -3149,15 +3149,10 @@ Parser::tryParseExceptionSpecification(bool Delayed, ExceptionSpecTokens->push_back(StartTok); // 'throw' or 'noexcept' ExceptionSpecTokens->push_back(Tok); // '(' SpecificationRange.setEnd(ConsumeParen()); // '(' - - if (!ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens, - /*StopAtSemi=*/true, - /*ConsumeFinalToken=*/true)) { - NoexceptExpr = 0; - delete ExceptionSpecTokens; - ExceptionSpecTokens = 0; - return IsNoexcept? EST_BasicNoexcept : EST_DynamicNone; - } + + ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens, + /*StopAtSemi=*/true, + /*ConsumeFinalToken=*/true); SpecificationRange.setEnd(Tok.getLocation()); // Add the 'stop' token. diff --git a/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp index b6eb1b46db5..0e9a3b9d54d 100644 --- a/clang/test/Parser/cxx-class.cpp +++ b/clang/test/Parser/cxx-class.cpp @@ -179,6 +179,14 @@ class X1 { a::operator=; }; // expected-error {{undeclared identifier 'a'}} class X2 { a::a; }; // expected-error {{undeclared identifier 'a'}} } +class BadExceptionSpec { + void f() throw(int; // expected-error {{expected ')'}} expected-note {{to match}} + void g() throw( // expected-note {{to match}} + int( // expected-note {{to match}} + ; // expected-error 2{{expected ')'}} expected-error {{unexpected end of exception specification}} + )); +}; + // PR11109 must appear at the end of the source file class pr11109r3 { // expected-note{{to match this '{'}} public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}} |