[cfe-commits] r71967 - in /cfe/trunk: lib/Parse/ParseExpr.cpp lib/Parse/ParseStmt.cpp test/Parser/extension.c test/SemaCXX/decl-expr-ambiguity.cpp
Eli Friedman
eli.friedman at gmail.com
Sat May 16 16:40:44 PDT 2009
Author: efriedma
Date: Sat May 16 18:40:44 2009
New Revision: 71967
URL: http://llvm.org/viewvc/llvm-project?rev=71967&view=rev
Log:
Make the RAII extension warning silencing for __extension__ a bit
narrower, so it doesn't catch expresions that aren't sub-expressions of
__extension__ operator.
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/test/Parser/extension.c
cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=71967&r1=71966&r2=71967&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Sat May 16 18:40:44 2009
@@ -225,8 +225,14 @@
/// process of disambiguating between an expression and a declaration.
Parser::OwningExprResult
Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) {
- OwningExprResult LHS(ParseCastExpression(false));
- if (LHS.isInvalid()) return move(LHS);
+ OwningExprResult LHS(Actions, true);
+ {
+ // Silence extension warnings in the sub-expression
+ ExtensionRAIIObject O(Diags);
+
+ LHS = ParseCastExpression(false);
+ if (LHS.isInvalid()) return move(LHS);
+ }
LHS = Actions.ActOnUnaryOp(CurScope, ExtLoc, tok::kw___extension__,
move(LHS));
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=71967&r1=71966&r2=71967&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Sat May 16 18:40:44 2009
@@ -435,13 +435,13 @@
SourceLocation ExtLoc = ConsumeToken();
while (Tok.is(tok::kw___extension__))
ConsumeToken();
-
- // __extension__ silences extension warnings in the subexpression.
- ExtensionRAIIObject O(Diags); // Use RAII to do this.
// If this is the start of a declaration, parse it as such.
if (isDeclarationStatement()) {
+ // __extension__ silences extension warnings in the subdeclaration.
// FIXME: Save the __extension__ on the decl as a node somehow?
+ ExtensionRAIIObject O(Diags);
+
SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
DeclGroupPtrTy Res = ParseDeclaration(Declarator::BlockContext,DeclEnd);
R = Actions.ActOnDeclStmt(Res, DeclStart, DeclEnd);
Modified: cfe/trunk/test/Parser/extension.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/extension.c?rev=71967&r1=71966&r2=71967&view=diff
==============================================================================
--- cfe/trunk/test/Parser/extension.c (original)
+++ cfe/trunk/test/Parser/extension.c Sat May 16 18:40:44 2009
@@ -1,17 +1,20 @@
-// RUN: clang-cc %s -fsyntax-only
+/* RUN: clang-cc %s -fsyntax-only -pedantic -verify -std=c89
+ */
-// Top level extension marker.
+/* Top level extension marker. */
__extension__ typedef struct
{
long long int quot;
long long int rem;
-}lldiv_t;
+} lldiv_t;
-// Compound expr __extension__ marker.
+/* Decl/expr __extension__ marker. */
void bar() {
__extension__ int i;
int j;
+ __extension__ (j = 10LL);
+ __extension__ j = 10LL; /* expected-warning {{'long long' is an extension}} */
}
Modified: cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp?rev=71967&r1=71966&r2=71967&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp (original)
+++ cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp Sat May 16 18:40:44 2009
@@ -9,7 +9,7 @@
T(a)->m = 7;
int(a)++; // expected-error {{expression is not assignable}}
__extension__ int(a)++; // expected-error {{expression is not assignable}}
- typeof(int)(a,5)<<a; // expected-error {{function-style cast to a builtin type can only take one argument}}
+ __typeof(int)(a,5)<<a; // expected-error {{function-style cast to a builtin type can only take one argument}}
void(a), ++a; // expected-warning {{expression result unused}}
if (int(a)+1) {}
for (int(a)+1;;) {}
More information about the cfe-commits
mailing list