@@ -3672,17 +3672,19 @@ Value *ScalarExprEmitter::VisitReal(const UnaryOperator *E,
3672
3672
// If it's an l-value, load through the appropriate subobject l-value.
3673
3673
// Note that we have to ask E because Op might be an l-value that
3674
3674
// this won't work for, e.g. an Obj-C property.
3675
- if (E->isGLValue ()) {
3675
+ if (E->isGLValue ()) {
3676
3676
if (!PromotionType.isNull ()) {
3677
3677
CodeGenFunction::ComplexPairTy result = CGF.EmitComplexExpr (
3678
3678
Op, /* IgnoreReal*/ IgnoreResultAssign, /* IgnoreImag*/ true );
3679
- if (result.first )
3680
- result.first = CGF.EmitPromotedValue (result, PromotionType).first ;
3681
- return result.first ;
3682
- } else {
3683
- return CGF.EmitLoadOfLValue (CGF.EmitLValue (E), E->getExprLoc ())
3684
- .getScalarVal ();
3679
+ PromotionType = PromotionType->isAnyComplexType ()
3680
+ ? PromotionType
3681
+ : CGF.getContext ().getComplexType (PromotionType);
3682
+ return result.first ? CGF.EmitPromotedValue (result, PromotionType).first
3683
+ : result.first ;
3685
3684
}
3685
+
3686
+ return CGF.EmitLoadOfLValue (CGF.EmitLValue (E), E->getExprLoc ())
3687
+ .getScalarVal ();
3686
3688
}
3687
3689
// Otherwise, calculate and project.
3688
3690
return CGF.EmitComplexExpr (Op, false , true ).first ;
@@ -3715,13 +3717,16 @@ Value *ScalarExprEmitter::VisitImag(const UnaryOperator *E,
3715
3717
if (!PromotionType.isNull ()) {
3716
3718
CodeGenFunction::ComplexPairTy result = CGF.EmitComplexExpr (
3717
3719
Op, /* IgnoreReal*/ true , /* IgnoreImag*/ IgnoreResultAssign);
3718
- if (result. second )
3719
- result. second = CGF. EmitPromotedValue (result, PromotionType). second ;
3720
- return result. second ;
3721
- } else {
3722
- return CGF.EmitLoadOfLValue (CGF. EmitLValue (E), E-> getExprLoc ())
3723
- . getScalarVal () ;
3720
+ PromotionType = PromotionType-> isAnyComplexType ( )
3721
+ ? PromotionType
3722
+ : CGF. getContext (). getComplexType (PromotionType) ;
3723
+ return result. second
3724
+ ? CGF.EmitPromotedValue (result, PromotionType). second
3725
+ : result. second ;
3724
3726
}
3727
+
3728
+ return CGF.EmitLoadOfLValue (CGF.EmitLValue (E), E->getExprLoc ())
3729
+ .getScalarVal ();
3725
3730
}
3726
3731
// Otherwise, calculate and project.
3727
3732
return CGF.EmitComplexExpr (Op, true , false ).second ;
0 commit comments