@@ -776,20 +776,11 @@ ExprResult Sema::CallExprUnaryConversions(Expr *E) {
776776 return Res.get();
777777}
778778
779- /// UsualUnaryConversions - Performs various conversions that are common to most
780- /// operators (C99 6.3). The conversions of array and function types are
781- /// sometimes suppressed. For example, the array->pointer conversion doesn't
782- /// apply if the array is an argument to the sizeof or address (&) operators.
783- /// In these instances, this routine should *not* be called.
784- ExprResult Sema::UsualUnaryConversions(Expr *E) {
785- // First, convert to an r-value.
786- ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
787- if (Res.isInvalid())
788- return ExprError();
789- E = Res.get();
790-
779+ /// UsualUnaryFPConversions - Promotes floating-point types according to the
780+ /// current language semantics.
781+ ExprResult Sema::UsualUnaryFPConversions(Expr *E) {
791782 QualType Ty = E->getType();
792- assert(!Ty.isNull() && "UsualUnaryConversions - missing type");
783+ assert(!Ty.isNull() && "UsualUnaryFPConversions - missing type");
793784
794785 LangOptions::FPEvalMethodKind EvalMethod = CurFPFeatures.getFPEvalMethod();
795786 if (EvalMethod != LangOptions::FEM_Source && Ty->isFloatingType() &&
@@ -827,7 +818,30 @@ ExprResult Sema::UsualUnaryConversions(Expr *E) {
827818
828819 // Half FP have to be promoted to float unless it is natively supported
829820 if (Ty->isHalfType() && !getLangOpts().NativeHalfType)
830- return ImpCastExprToType(Res.get(), Context.FloatTy, CK_FloatingCast);
821+ return ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast);
822+
823+ return E;
824+ }
825+
826+ /// UsualUnaryConversions - Performs various conversions that are common to most
827+ /// operators (C99 6.3). The conversions of array and function types are
828+ /// sometimes suppressed. For example, the array->pointer conversion doesn't
829+ /// apply if the array is an argument to the sizeof or address (&) operators.
830+ /// In these instances, this routine should *not* be called.
831+ ExprResult Sema::UsualUnaryConversions(Expr *E) {
832+ // First, convert to an r-value.
833+ ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
834+ if (Res.isInvalid())
835+ return ExprError();
836+
837+ // Promote floating-point types.
838+ Res = UsualUnaryFPConversions(Res.get());
839+ if (Res.isInvalid())
840+ return ExprError();
841+ E = Res.get();
842+
843+ QualType Ty = E->getType();
844+ assert(!Ty.isNull() && "UsualUnaryConversions - missing type");
831845
832846 // Try to perform integral promotions if the object has a theoretically
833847 // promotable type.
0 commit comments