@@ -411,6 +411,33 @@ LValue CIRGenFunction::buildLValueForFieldInitialization(
411
411
return makeAddrLValue (V, FieldType, FieldBaseInfo);
412
412
}
413
413
414
+ LValue
415
+ CIRGenFunction::buildCompoundLiteralLValue (const CompoundLiteralExpr *E) {
416
+ if (E->isFileScope ()) {
417
+ llvm_unreachable (" NYI" );
418
+ }
419
+
420
+ if (E->getType ()->isVariablyModifiedType ()) {
421
+ llvm_unreachable (" NYI" );
422
+ }
423
+
424
+ Address DeclPtr = CreateMemTemp (E->getType (), getLoc (E->getSourceRange ()),
425
+ " .compoundliteral" );
426
+ const Expr *InitExpr = E->getInitializer ();
427
+ LValue Result = makeAddrLValue (DeclPtr, E->getType (), AlignmentSource::Decl);
428
+
429
+ buildAnyExprToMem (InitExpr, DeclPtr, E->getType ().getQualifiers (),
430
+ /* Init*/ true );
431
+
432
+ // Block-scope compound literals are destroyed at the end of the enclosing
433
+ // scope in C.
434
+ if (!getLangOpts ().CPlusPlus )
435
+ if (QualType::DestructionKind DtorKind = E->getType ().isDestructedType ())
436
+ llvm_unreachable (" NYI" );
437
+
438
+ return Result;
439
+ }
440
+
414
441
// Detect the unusual situation where an inline version is shadowed by a
415
442
// non-inline version. In that case we should pick the external one
416
443
// everywhere. That's GCC behavior too.
@@ -2241,6 +2268,8 @@ LValue CIRGenFunction::buildLValue(const Expr *E) {
2241
2268
return buildStringLiteralLValue (cast<StringLiteral>(E));
2242
2269
case Expr::MemberExprClass:
2243
2270
return buildMemberExpr (cast<MemberExpr>(E));
2271
+ case Expr::CompoundLiteralExprClass:
2272
+ return buildCompoundLiteralLValue (cast<CompoundLiteralExpr>(E));
2244
2273
case Expr::PredefinedExprClass:
2245
2274
return buildPredefinedLValue (cast<PredefinedExpr>(E));
2246
2275
case Expr::CXXFunctionalCastExprClass:
0 commit comments