[clang] [Clang] Initializer list on RHS of assignment (PR #100548)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 25 06:48:34 PDT 2024
================
@@ -14578,21 +14578,56 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
BinaryOperatorKind Opc,
Expr *LHSExpr, Expr *RHSExpr) {
if (getLangOpts().CPlusPlus11 && isa<InitListExpr>(RHSExpr)) {
- // The syntax only allows initializer lists on the RHS of assignment,
- // so we don't need to worry about accepting invalid code for
- // non-assignment operators.
- // C++11 5.17p9:
- // The meaning of x = {v} [...] is that of x = T(v) [...]. The meaning
- // of x = {} is x = T().
- InitializationKind Kind = InitializationKind::CreateDirectList(
- RHSExpr->getBeginLoc(), RHSExpr->getBeginLoc(), RHSExpr->getEndLoc());
- InitializedEntity Entity =
- InitializedEntity::InitializeTemporary(LHSExpr->getType());
- InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr);
- ExprResult Init = InitSeq.Perform(*this, Entity, Kind, RHSExpr);
- if (Init.isInvalid())
- return Init;
- RHSExpr = Init.get();
+ // C++11 [expr.ass]p9, per CWG2768:
----------------
cor3ntin wrote:
I'd rather quote a version of the standard to which the wording is applied
https://github.com/llvm/llvm-project/pull/100548
More information about the cfe-commits
mailing list