summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-11-20 02:04:01 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-11-20 02:04:01 +0000
commitde2bdf637ed7f2ade02bebde801ee1a9fe3ea68d (patch)
tree3abece97fff722b40ebff9f6b3f76d12096fe583 /clang/lib/Parse/ParseStmt.cpp
parent9331ed89f8d3466c9389b7e9ef7b69c877ffbea2 (diff)
downloadbcm5719-llvm-de2bdf637ed7f2ade02bebde801ee1a9fe3ea68d.tar.gz
bcm5719-llvm-de2bdf637ed7f2ade02bebde801ee1a9fe3ea68d.zip
Revert r119838 "Don't warn for empty 'if' body if there is a macro that expands to nothing"
and use a better and more general approach, where NullStmt has a flag to indicate whether it was preceded by an empty macro. Thanks to Abramo Bagnara for the hint! llvm-svn: 119887
Diffstat (limited to 'clang/lib/Parse/ParseStmt.cpp')
-rw-r--r--clang/lib/Parse/ParseStmt.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index e3c15680c23..26d2279d31e 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -147,8 +147,10 @@ Parser::ParseStatementOrDeclaration(StmtVector &Stmts, bool OnlyStatement) {
case tok::l_brace: // C99 6.8.2: compound-statement
return ParseCompoundStatement(AttrList);
- case tok::semi: // C99 6.8.3p3: expression[opt] ';'
- return Actions.ActOnNullStmt(ConsumeToken());
+ case tok::semi: { // C99 6.8.3p3: expression[opt] ';'
+ bool LeadingEmptyMacro = Tok.hasLeadingEmptyMacro();
+ return Actions.ActOnNullStmt(ConsumeToken(), LeadingEmptyMacro);
+ }
case tok::kw_if: // C99 6.8.4.1: if-statement
return ParseIfStatement(AttrList);
@@ -538,8 +540,7 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
bool Parser::ParseParenExprOrCondition(ExprResult &ExprResult,
Decl *&DeclResult,
SourceLocation Loc,
- bool ConvertToBoolean,
- bool *MacroExpandedAfterRParen) {
+ bool ConvertToBoolean) {
bool ParseError = false;
SourceLocation LParenLoc = ConsumeParen();
@@ -568,14 +569,7 @@ bool Parser::ParseParenExprOrCondition(ExprResult &ExprResult,
}
// Otherwise the condition is valid or the rparen is present.
-
- // Catch a macro expansion after ')'. This is used to know that there is a
- // macro for 'if' body and not warn for empty body if the macro is empty.
- PPMacroExpansionTrap MacroExpansionTrap(PP);
MatchRHSPunctuation(tok::r_paren, LParenLoc);
- if (MacroExpandedAfterRParen)
- *MacroExpandedAfterRParen = MacroExpansionTrap.hasMacroExpansionOccured();
-
return false;
}
@@ -618,9 +612,7 @@ StmtResult Parser::ParseIfStatement(AttributeList *Attr) {
// Parse the condition.
ExprResult CondExp;
Decl *CondVar = 0;
- bool MacroExpandedInThenStmt;
- if (ParseParenExprOrCondition(CondExp, CondVar, IfLoc, true,
- &MacroExpandedInThenStmt))
+ if (ParseParenExprOrCondition(CondExp, CondVar, IfLoc, true))
return StmtError();
FullExprArg FullCondExp(Actions.MakeFullExpr(CondExp.get()));
@@ -704,7 +696,7 @@ StmtResult Parser::ParseIfStatement(AttributeList *Attr) {
ElseStmt = Actions.ActOnNullStmt(ElseStmtLoc);
return Actions.ActOnIfStmt(IfLoc, FullCondExp, CondVar, ThenStmt.get(),
- MacroExpandedInThenStmt, ElseLoc, ElseStmt.get());
+ ElseLoc, ElseStmt.get());
}
/// ParseSwitchStatement
OpenPOWER on IntegriCloud