[PATCH] D57984: PR40642: Fix determination of whether the final statement of a statementexpression is a discarded-value expression.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 8 16:06:33 PST 2019


rsmith created this revision.
rsmith added reviewers: aaron.ballman, rjmccall.
Herald added a project: clang.

We used to get this wrong in three ways:

1. During parsing, an expression-statement followed by the }) ending a

statement expression was always treated as producing the value of the
statement expression. That's wrong for ({ if (1) expr; })

2. During template instantiation, various kinds of statement (most

statements not appearing directly in a compound-statement) were not
treated as discarded-value expressions, resulting in missing volatile
loads (etc).

3. In all contexts, an expression-statement with attributes was not

treated as producing the value of the statement expression, eg
({ [[attr]] expr; }).


Repository:
  rC Clang

https://reviews.llvm.org/D57984

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  include/clang/Basic/StmtNodes.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/AST/Stmt.cpp
  lib/CodeGen/CGStmt.cpp
  lib/Parse/ParseObjc.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/TreeTransform.h
  test/CodeGenCXX/stmtexpr.cpp
  test/CodeGenCXX/volatile.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57984.186066.patch
Type: text/x-patch
Size: 35759 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190209/b32e3e08/attachment-0001.bin>


More information about the cfe-commits mailing list