[clang] Reapply "[Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer" (PR #97308)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 30 01:49:37 PDT 2024
================
@@ -750,8 +750,33 @@ void InitListChecker::FillInEmptyInitForField(unsigned Init, FieldDecl *Field,
if (Field->hasInClassInitializer()) {
if (VerifyOnly)
return;
-
- ExprResult DIE = SemaRef.BuildCXXDefaultInitExpr(Loc, Field);
+ ExprResult DIE;
+ {
+ // Enter a lifetime extension context, then we can support lifetime
+ // extension of temporary created by aggregate initialization using a
+ // default member initializer (DR1815 https://wg21.link/CWG1815).
+ //
+ // In a lifetime extension context, BuildCXXDefaultInitExpr will clone
+ // the initializer expression on each use and the temporaries which
----------------
cor3ntin wrote:
```suggestion
// the initializer expression for each use and the temporaries which
```
https://github.com/llvm/llvm-project/pull/97308
More information about the cfe-commits
mailing list