diff options
-rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 10 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/references.cpp | 8 |
2 files changed, 13 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 667fe6714b4..cb6e1d81403 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -514,13 +514,13 @@ void AggExprEmitter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) { void AggExprEmitter::EmitInitializationToLValue(Expr* E, LValue LV, QualType T) { - // FIXME: Remove this. - T = E->getType(); - // FIXME: Ignore result? // FIXME: Are initializers affected by volatile? if (isa<ImplicitValueInitExpr>(E)) { EmitNullInitializationToLValue(LV, T); + } else if (T->isReferenceType()) { + RValue RV = CGF.EmitReferenceBindingToExpr(E, /*IsInitializer=*/false); + CGF.EmitStoreThroughLValue(RV, LV, T); } else if (T->isAnyComplexType()) { CGF.EmitComplexExprIntoAddr(E, LV.getAddress(), false); } else if (CGF.hasAggregateLLVMType(T)) { @@ -633,7 +633,7 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) { // FIXME: volatility FieldDecl *Field = E->getInitializedFieldInUnion(); - LValue FieldLoc = CGF.EmitLValueForField(DestPtr, Field, 0); + LValue FieldLoc = CGF.EmitLValueForFieldInitialization(DestPtr, Field, 0); if (NumInitElements) { // Store the initializer into the field @@ -659,7 +659,7 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) { continue; // FIXME: volatility - LValue FieldLoc = CGF.EmitLValueForField(DestPtr, *Field, 0); + LValue FieldLoc = CGF.EmitLValueForFieldInitialization(DestPtr, *Field, 0); // We never generate write-barries for initialized fields. LValue::SetObjCNonGC(FieldLoc, true); if (CurInitVal < NumInitElements) { diff --git a/clang/test/CodeGenCXX/references.cpp b/clang/test/CodeGenCXX/references.cpp index 6bec8bd8c38..39b5909fb9a 100644 --- a/clang/test/CodeGenCXX/references.cpp +++ b/clang/test/CodeGenCXX/references.cpp @@ -38,6 +38,8 @@ void test_bool() { bool_reference_return() = true; a = bool_reference_return(); + + struct { const bool& b; } b = { true }; } void test_scalar() { @@ -54,6 +56,8 @@ void test_scalar() { int_reference_return() = 10; a = int_reference_return(); + + struct { const int& a; } agg = { 10 }; } void test_complex() { @@ -64,6 +68,8 @@ void test_complex() { complex_int_reference_return() = 10i; a = complex_int_reference_return(); + + struct { const _Complex int &a; } agg = { 10i }; } void test_aggregate() { @@ -74,6 +80,8 @@ void test_aggregate() { aggregate_reference_return().a = 10; c = aggregate_reference_return(); + + struct { const C& a; } agg = { C() }; } int& reference_return() { |