File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -662,6 +662,16 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
662
662
663
663
return ;
664
664
}
665
+
666
+ // If we're initializing the whole aggregate, just do it in place.
667
+ // FIXME: This is a hack around an AST bug (PR6537).
668
+ if (NumInitElements == 1 && E->getType () == E->getInit (0 )->getType ()) {
669
+ EmitInitializationToLValue (E->getInit (0 ),
670
+ LValue::MakeAddr (DestPtr, Qualifiers ()),
671
+ E->getType ());
672
+ return ;
673
+ }
674
+
665
675
666
676
// Here we iterate over the fields; this makes it simpler to both
667
677
// default-initialize fields and skip over unnamed fields.
@@ -680,8 +690,8 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
680
690
// We never generate write-barries for initialized fields.
681
691
LValue::SetObjCNonGC (FieldLoc, true );
682
692
if (CurInitVal < NumInitElements) {
683
- // Store the initializer into the field
684
- EmitInitializationToLValue (E->getInit (CurInitVal++), FieldLoc,
693
+ // Store the initializer into the field.
694
+ EmitInitializationToLValue (E->getInit (CurInitVal++), FieldLoc,
685
695
Field->getType ());
686
696
} else {
687
697
// We're out of initalizers; default-initialize to null
Original file line number Diff line number Diff line change @@ -29,3 +29,14 @@ int f4() {
29
29
static const int g4 = 12 ;
30
30
return g4 ;
31
31
}
32
+
33
+ // PR6537
34
+ typedef union vec3 {
35
+ struct { double x , y , z ; };
36
+ double component [3 ];
37
+ } vec3 ;
38
+ vec3 f5 (vec3 value ) {
39
+ return (vec3 ) {{
40
+ .x = value .x
41
+ }};
42
+ }
You can’t perform that action at this time.
0 commit comments