@@ -280,6 +280,10 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
280
280
return true ;
281
281
}
282
282
283
+ case CK_IntegralComplexToReal:
284
+ case CK_FloatingComplexToReal:
285
+ return this ->emitComplexReal (SubExpr);
286
+
283
287
case CK_ToVoid:
284
288
return discard (SubExpr);
285
289
@@ -2023,7 +2027,7 @@ bool ByteCodeExprGen<Emitter>::dereference(
2023
2027
}
2024
2028
2025
2029
if (LV->getType ()->isAnyComplexType ())
2026
- return visit (LV);
2030
+ return this -> delegate (LV);
2027
2031
2028
2032
return false ;
2029
2033
}
@@ -2760,21 +2764,9 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
2760
2764
if (!this ->visit (SubExpr))
2761
2765
return false ;
2762
2766
return DiscardResult ? this ->emitPop (*T, E) : this ->emitComp (*T, E);
2763
- case UO_Real: { // __real x
2767
+ case UO_Real: // __real x
2764
2768
assert (!T);
2765
- if (!this ->visit (SubExpr))
2766
- return false ;
2767
- if (!this ->emitConstUint8 (0 , E))
2768
- return false ;
2769
- if (!this ->emitArrayElemPtrPopUint8 (E))
2770
- return false ;
2771
-
2772
- // Since our _Complex implementation does not map to a primitive type,
2773
- // we sometimes have to do the lvalue-to-rvalue conversion here manually.
2774
- if (!SubExpr->isLValue ())
2775
- return this ->emitLoadPop (classifyPrim (E->getType ()), E);
2776
- return true ;
2777
- }
2769
+ return this ->emitComplexReal (SubExpr);
2778
2770
case UO_Imag: { // __imag x
2779
2771
assert (!T);
2780
2772
if (!this ->visit (SubExpr))
@@ -2941,6 +2933,29 @@ bool ByteCodeExprGen<Emitter>::emitPrimCast(PrimType FromT, PrimType ToT,
2941
2933
return false ;
2942
2934
}
2943
2935
2936
+ // / Emits __real(SubExpr)
2937
+ template <class Emitter >
2938
+ bool ByteCodeExprGen<Emitter>::emitComplexReal(const Expr *SubExpr) {
2939
+ assert (SubExpr->getType ()->isAnyComplexType ());
2940
+
2941
+ if (DiscardResult)
2942
+ return this ->discard (SubExpr);
2943
+
2944
+ if (!this ->visit (SubExpr))
2945
+ return false ;
2946
+ if (!this ->emitConstUint8 (0 , SubExpr))
2947
+ return false ;
2948
+ if (!this ->emitArrayElemPtrPopUint8 (SubExpr))
2949
+ return false ;
2950
+
2951
+ // Since our _Complex implementation does not map to a primitive type,
2952
+ // we sometimes have to do the lvalue-to-rvalue conversion here manually.
2953
+ if (!SubExpr->isLValue ())
2954
+ return this ->emitLoadPop (*classifyComplexElementType (SubExpr->getType ()),
2955
+ SubExpr);
2956
+ return true ;
2957
+ }
2958
+
2944
2959
// / When calling this, we have a pointer of the local-to-destroy
2945
2960
// / on the stack.
2946
2961
// / Emit destruction of record types (or arrays of record types).
0 commit comments