r322779 - [Sema] Allow conversion between long double and __float128.
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 17 14:56:57 PST 2018
Author: d0k
Date: Wed Jan 17 14:56:57 2018
New Revision: 322779
URL: http://llvm.org/viewvc/llvm-project?rev=322779&view=rev
Log:
[Sema] Allow conversion between long double and __float128.
We should only ban this if long double is a double double. x86's 80 bit
long double is fine and supported by the backend.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/Sema/float128-ld-incompatibility.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=322779&r1=322778&r2=322779&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jan 17 14:56:57 2018
@@ -1092,13 +1092,12 @@ static bool unsupportedTypeConversion(co
Float128AndLongDouble |= (LHSElemType == S.Context.LongDoubleTy &&
RHSElemType == S.Context.Float128Ty);
- /* We've handled the situation where __float128 and long double have the same
- representation. The only other allowable conversion is if long double is
- really just double.
- */
+ // We've handled the situation where __float128 and long double have the same
+ // representation. We allow all conversions for all possible long double types
+ // except PPC's double double.
return Float128AndLongDouble &&
- (&S.Context.getFloatTypeSemantics(S.Context.LongDoubleTy) !=
- &llvm::APFloat::IEEEdouble());
+ (&S.Context.getFloatTypeSemantics(S.Context.LongDoubleTy) ==
+ &llvm::APFloat::PPCDoubleDouble());
}
typedef ExprResult PerformCastFn(Sema &S, Expr *operand, QualType toType);
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=322779&r1=322778&r2=322779&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jan 17 14:56:57 2018
@@ -1764,8 +1764,8 @@ static bool IsStandardConversion(Sema &S
(FromType == S.Context.LongDoubleTy &&
ToType == S.Context.Float128Ty));
if (Float128AndLongDouble &&
- (&S.Context.getFloatTypeSemantics(S.Context.LongDoubleTy) !=
- &llvm::APFloat::IEEEdouble()))
+ (&S.Context.getFloatTypeSemantics(S.Context.LongDoubleTy) ==
+ &llvm::APFloat::PPCDoubleDouble()))
return false;
}
// Floating point conversions (C++ 4.8).
Modified: cfe/trunk/test/Sema/float128-ld-incompatibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/float128-ld-incompatibility.cpp?rev=322779&r1=322778&r2=322779&view=diff
==============================================================================
--- cfe/trunk/test/Sema/float128-ld-incompatibility.cpp (original)
+++ cfe/trunk/test/Sema/float128-ld-incompatibility.cpp Wed Jan 17 14:56:57 2018
@@ -1,10 +1,12 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
// RUN: -triple powerpc64le-unknown-linux-gnu -target-cpu pwr8 \
// RUN: -target-feature +float128 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -triple x86_64-unknown-linux-gnu -Wno-unused-value -Wno-parentheses %s
__float128 qf();
long double ldf();
+#ifdef __PPC__
// FIXME: once operations between long double and __float128 are implemented for
// targets where the types are different, these next two will change
long double ld{qf()}; // expected-error {{cannot initialize a variable of type 'long double' with an rvalue of type '__float128'}}
@@ -17,6 +19,7 @@ auto test1(__float128 q, long double ld)
auto test2(long double a, __float128 b) -> decltype(a + b) { // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
return a + b; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
}
+#endif
void test3(bool b) {
long double ld;
More information about the cfe-commits
mailing list