diff options
author | Chris Lattner <sabre@nondot.org> | 2008-10-20 06:51:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-10-20 06:51:33 +0000 |
commit | 1ff6e73651fc6ff59d443412a4422f391d97a465 (patch) | |
tree | 0c0762ae9323183dbb3a67621fc173560c4bd3c9 /clang/lib/Parse/ParseStmt.cpp | |
parent | f02ef3e6d4a3367f0473f3d81bb3080f51be7488 (diff) | |
download | bcm5719-llvm-1ff6e73651fc6ff59d443412a4422f391d97a465.tar.gz bcm5719-llvm-1ff6e73651fc6ff59d443412a4422f391d97a465.zip |
simplify some other code for __extension__ processing.
llvm-svn: 57807
Diffstat (limited to 'clang/lib/Parse/ParseStmt.cpp')
-rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 228bc4886ca..f5cdfffba50 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "clang/Parse/Parser.h" +#include "ExtensionRAIIObject.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceManager.h" #include "clang/Parse/DeclSpec.h" @@ -364,9 +365,8 @@ Parser::StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { ConsumeToken(); // __extension__ silences extension warnings in the subexpression. - bool SavedExtWarn = Diags.getWarnOnExtensions(); - Diags.setWarnOnExtensions(false); - + ExtensionRAIIObject O(Diags); // Use RAII to do this. + // If this is the start of a declaration, parse it as such. if (isDeclarationStatement()) { // FIXME: Save the __extension__ on the decl as a node somehow. @@ -374,13 +374,10 @@ Parser::StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { DeclTy *Res = ParseDeclaration(Declarator::BlockContext); // FIXME: Pass in the right location for the end of the declstmt. R = Actions.ActOnDeclStmt(Res, DeclStart, DeclStart); - - Diags.setWarnOnExtensions(SavedExtWarn); } else { // Otherwise this was a unary __extension__ marker. Parse the // subexpression and add the __extension__ unary op. ExprResult Res = ParseCastExpression(false); - Diags.setWarnOnExtensions(SavedExtWarn); if (Res.isInvalid) { SkipUntil(tok::semi); @@ -392,7 +389,8 @@ Parser::StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { if (Res.isInvalid) continue; - // Eat the semicolon at the end of stmt and convert the expr into a stmt. + // Eat the semicolon at the end of stmt and convert the expr into a + // statement. ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr); R = Actions.ActOnExprStmt(Res.Val); } |