diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2019-07-09 15:02:07 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2019-07-09 15:02:07 +0000 |
commit | b1e511bf5a4c702ace445848b30070ac2e021241 (patch) | |
tree | 22de771c7632577d77a3949f333a3231e4ac193a /clang/lib/Sema/TreeTransform.h | |
parent | d95557306585404893d610784edb3e32f1bfce18 (diff) | |
download | bcm5719-llvm-b1e511bf5a4c702ace445848b30070ac2e021241.tar.gz bcm5719-llvm-b1e511bf5a4c702ace445848b30070ac2e021241.zip |
Ignore trailing NullStmts in StmtExprs for GCC compatibility.
Ignore trailing NullStmts in compound expressions when determining the result type and value. This is to match the GCC behavior which ignores semicolons at the end of compound expressions.
Patch by Dominic Ferreira.
llvm-svn: 365498
Diffstat (limited to 'clang/lib/Sema/TreeTransform.h')
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 7edb2a8d809..a6122c93384 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -6612,13 +6612,13 @@ TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr) { Sema::CompoundScopeRAII CompoundScope(getSema()); + const Stmt *ExprResult = S->getStmtExprResult(); bool SubStmtInvalid = false; bool SubStmtChanged = false; SmallVector<Stmt*, 8> Statements; for (auto *B : S->body()) { StmtResult Result = getDerived().TransformStmt( - B, - IsStmtExpr && B == S->body_back() ? SDK_StmtExprResult : SDK_Discarded); + B, IsStmtExpr && B == ExprResult ? SDK_StmtExprResult : SDK_Discarded); if (Result.isInvalid()) { // Immediately fail if this was a DeclStmt, since it's very |