summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-05-16 23:40:44 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-05-16 23:40:44 +0000
commit15af3ee6a9f145332b29cb5d3d40746df17a5f07 (patch)
tree163497dc4e12d449a3343ac14a60dd76d6bd0a65
parent678d3bac03704bb8eb200b6eaf2481d8506029cc (diff)
downloadbcm5719-llvm-15af3ee6a9f145332b29cb5d3d40746df17a5f07.tar.gz
bcm5719-llvm-15af3ee6a9f145332b29cb5d3d40746df17a5f07.zip
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. llvm-svn: 71967
-rw-r--r--clang/lib/Parse/ParseExpr.cpp10
-rw-r--r--clang/lib/Parse/ParseStmt.cpp6
-rw-r--r--clang/test/Parser/extension.c11
-rw-r--r--clang/test/SemaCXX/decl-expr-ambiguity.cpp2
4 files changed, 19 insertions, 10 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 20c55a1ea38..55fc0cdd6c6 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -225,8 +225,14 @@ Parser::ParseExpressionWithLeadingAt(SourceLocation AtLoc) {
/// 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));
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index d0d462b66ce..50db966aedb 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -435,13 +435,13 @@ Parser::OwningStmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
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);
diff --git a/clang/test/Parser/extension.c b/clang/test/Parser/extension.c
index 24f1ac5181a..519dc053c82 100644
--- a/clang/test/Parser/extension.c
+++ b/clang/test/Parser/extension.c
@@ -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}} */
}
diff --git a/clang/test/SemaCXX/decl-expr-ambiguity.cpp b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
index a9275dcd1fd..bff333464b9 100644
--- a/clang/test/SemaCXX/decl-expr-ambiguity.cpp
+++ b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -9,7 +9,7 @@ void f() {
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;;) {}
OpenPOWER on IntegriCloud