r225755 - 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.
Richard Smith
richard-llvm at metafoo.co.uk
Mon Jan 12 18:24:59 PST 2015
Author: rsmith
Date: Mon Jan 12 20:24:58 2015
New Revision: 225755
URL: http://llvm.org/viewvc/llvm-project?rev=225755&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/test/Parser/cxx-class.cpp
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=225755&r1=225754&r2=225755&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Jan 12 20:24:58 2015
@@ -3149,15 +3149,10 @@ Parser::tryParseExceptionSpecification(b
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.
Modified: cfe/trunk/test/Parser/cxx-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-class.cpp?rev=225755&r1=225754&r2=225755&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-class.cpp (original)
+++ cfe/trunk/test/Parser/cxx-class.cpp Mon Jan 12 20:24:58 2015
@@ -179,6 +179,14 @@ class X1 { a::operator=; }; // expected-
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}}
More information about the cfe-commits
mailing list