@@ -287,6 +287,10 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
287
287
return true ;
288
288
}
289
289
290
+ case CK_IntegralComplexToReal:
291
+ case CK_FloatingComplexToReal:
292
+ return this ->emitComplexReal (SubExpr);
293
+
290
294
case CK_ToVoid:
291
295
return discard (SubExpr);
292
296
@@ -2030,7 +2034,7 @@ bool ByteCodeExprGen<Emitter>::dereference(
2030
2034
}
2031
2035
2032
2036
if (LV->getType ()->isAnyComplexType ())
2033
- return visit (LV);
2037
+ return this -> delegate (LV);
2034
2038
2035
2039
return false ;
2036
2040
}
@@ -2767,22 +2771,10 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
2767
2771
if (!this ->visit (SubExpr))
2768
2772
return false ;
2769
2773
return DiscardResult ? this ->emitPop (*T, E) : this ->emitComp (*T, E);
2770
- case UO_Real: { // __real x
2774
+ case UO_Real: // __real x
2771
2775
if (T)
2772
2776
return this ->delegate (SubExpr);
2773
- if (!this ->visit (SubExpr))
2774
- return false ;
2775
- if (!this ->emitConstUint8 (0 , E))
2776
- return false ;
2777
- if (!this ->emitArrayElemPtrPopUint8 (E))
2778
- return false ;
2779
-
2780
- // Since our _Complex implementation does not map to a primitive type,
2781
- // we sometimes have to do the lvalue-to-rvalue conversion here manually.
2782
- if (!SubExpr->isLValue ())
2783
- return this ->emitLoadPop (classifyPrim (E->getType ()), E);
2784
- return true ;
2785
- }
2777
+ return this ->emitComplexReal (SubExpr);
2786
2778
case UO_Imag: { // __imag x
2787
2779
if (T) {
2788
2780
if (!this ->discard (SubExpr))
@@ -2953,6 +2945,29 @@ bool ByteCodeExprGen<Emitter>::emitPrimCast(PrimType FromT, PrimType ToT,
2953
2945
return false ;
2954
2946
}
2955
2947
2948
+ // / Emits __real(SubExpr)
2949
+ template <class Emitter >
2950
+ bool ByteCodeExprGen<Emitter>::emitComplexReal(const Expr *SubExpr) {
2951
+ assert (SubExpr->getType ()->isAnyComplexType ());
2952
+
2953
+ if (DiscardResult)
2954
+ return this ->discard (SubExpr);
2955
+
2956
+ if (!this ->visit (SubExpr))
2957
+ return false ;
2958
+ if (!this ->emitConstUint8 (0 , SubExpr))
2959
+ return false ;
2960
+ if (!this ->emitArrayElemPtrPopUint8 (SubExpr))
2961
+ return false ;
2962
+
2963
+ // Since our _Complex implementation does not map to a primitive type,
2964
+ // we sometimes have to do the lvalue-to-rvalue conversion here manually.
2965
+ if (!SubExpr->isLValue ())
2966
+ return this ->emitLoadPop (*classifyComplexElementType (SubExpr->getType ()),
2967
+ SubExpr);
2968
+ return true ;
2969
+ }
2970
+
2956
2971
// / When calling this, we have a pointer of the local-to-destroy
2957
2972
// / on the stack.
2958
2973
// / Emit destruction of record types (or arrays of record types).
0 commit comments