[cfe-commits] r57807 - in /cfe/trunk/lib/Parse: ParseStmt.cpp Parser.cpp

Chris Lattner sabre at nondot.org
Sun Oct 19 23:51:33 PDT 2008


Author: lattner
Date: Mon Oct 20 01:51:33 2008
New Revision: 57807

URL: http://llvm.org/viewvc/llvm-project?rev=57807&view=rev
Log:
simplify some other code for __extension__ processing.

Modified:
    cfe/trunk/lib/Parse/ParseStmt.cpp
    cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=57807&r1=57806&r2=57807&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Mon Oct 20 01:51:33 2008
@@ -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 @@
         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 @@
         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 @@
         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);
       }

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=57807&r1=57806&r2=57807&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Mon Oct 20 01:51:33 2008
@@ -344,6 +344,7 @@
   case tok::kw___extension__: {
     // __extension__ silences extension warnings in the subexpression.
     ExtensionRAIIObject O(Diags);  // Use RAII to do this.
+    ConsumeToken();
     return ParseExternalDeclaration();
   }
   case tok::kw_asm: {





More information about the cfe-commits mailing list