[cfe-commits] r46669 - in /cfe/trunk: Parse/ParseExpr.cpp test/Sema/exprs.c

Chris Lattner sabre at nondot.org
Sat Feb 2 12:20:10 PST 2008


Author: lattner
Date: Sat Feb  2 14:20:10 2008
New Revision: 46669

URL: http://llvm.org/viewvc/llvm-project?rev=46669&view=rev
Log:
Implement support for __extension__ which silences extwarnings in its 
scope.  This is part of the fix for PR1966

Added:
    cfe/trunk/test/Sema/exprs.c
Modified:
    cfe/trunk/Parse/ParseExpr.cpp

Modified: cfe/trunk/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseExpr.cpp?rev=46669&r1=46668&r2=46669&view=diff

==============================================================================
--- cfe/trunk/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/Parse/ParseExpr.cpp Sat Feb  2 14:20:10 2008
@@ -567,13 +567,23 @@
   case tok::tilde:         // unary-expression: '~' cast-expression
   case tok::exclaim:       // unary-expression: '!' cast-expression
   case tok::kw___real:     // unary-expression: '__real' cast-expression [GNU]
-  case tok::kw___imag:     // unary-expression: '__imag' cast-expression [GNU]
+  case tok::kw___imag: {   // unary-expression: '__imag' cast-expression [GNU]
+    SourceLocation SavedLoc = ConsumeToken();
+    Res = ParseCastExpression(false);
+    if (!Res.isInvalid)
+      Res = Actions.ActOnUnaryOp(SavedLoc, SavedKind, Res.Val);
+    return Res;
+  }    
+      
   case tok::kw___extension__:{//unary-expression:'__extension__' cast-expr [GNU]
-    // FIXME: Extension should silence extwarns in subexpressions.
+    // __extension__ silences extension warnings in the subexpression.
+    bool SavedExtWarn = Diags.getWarnOnExtensions();
+    Diags.setWarnOnExtensions(false);
     SourceLocation SavedLoc = ConsumeToken();
     Res = ParseCastExpression(false);
     if (!Res.isInvalid)
       Res = Actions.ActOnUnaryOp(SavedLoc, SavedKind, Res.Val);
+    Diags.setWarnOnExtensions(SavedExtWarn);
     return Res;
   }
   case tok::kw_sizeof:     // unary-expression: 'sizeof' unary-expression

Added: cfe/trunk/test/Sema/exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/exprs.c?rev=46669&view=auto

==============================================================================
--- cfe/trunk/test/Sema/exprs.c (added)
+++ cfe/trunk/test/Sema/exprs.c Sat Feb  2 14:20:10 2008
@@ -0,0 +1,11 @@
+// RUN: clang %s -verify -pedantic -fsyntax-only
+
+// PR1966
+_Complex double test1() {
+  return __extension__ 1.0if;
+}
+
+_Complex double test2() {
+  return 1.0if;    // expected-warning {{imaginary constants are an extension}}
+}
+





More information about the cfe-commits mailing list