summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
diff options
context:
space:
mode:
authorNemanja Ivanovic <nemanja.i.ibm@gmail.com>2016-04-13 09:49:45 +0000
committerNemanja Ivanovic <nemanja.i.ibm@gmail.com>2016-04-13 09:49:45 +0000
commit50f29e06a1b6a38f0bba9360cbff72c82d46cdd4 (patch)
treedafe15670e279782025753c242bb713734e47cb6 /clang/test/Sema
parentb6ef8b730d483a70cd4d313b299789ad76b9da6f (diff)
downloadbcm5719-llvm-50f29e06a1b6a38f0bba9360cbff72c82d46cdd4.tar.gz
bcm5719-llvm-50f29e06a1b6a38f0bba9360cbff72c82d46cdd4.zip
Enable support for __float128 in Clang
This patch corresponds to review: http://reviews.llvm.org/D15120 It adds support for the __float128 keyword, literals and a target feature to enable it. This support is disabled by default on all targets and any target that has support for this type is free to add it. Based on feedback that I've received from target maintainers, this appears to be the right thing for most targets. I have not heard from the maintainers of X86 which I believe supports this type. I will subsequently investigate the impact of enabling this on X86. llvm-svn: 266186
Diffstat (limited to 'clang/test/Sema')
-rw-r--r--clang/test/Sema/128bitfloat.cpp16
-rw-r--r--clang/test/Sema/float128-ld-incompatibility.cpp36
2 files changed, 44 insertions, 8 deletions
diff --git a/clang/test/Sema/128bitfloat.cpp b/clang/test/Sema/128bitfloat.cpp
index cb76dac9600..779c59dfd4a 100644
--- a/clang/test/Sema/128bitfloat.cpp
+++ b/clang/test/Sema/128bitfloat.cpp
@@ -2,23 +2,23 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
#if !defined(__STRICT_ANSI__)
-__float128 f; // expected-error {{support for type '__float128' is not yet implemented}}
+__float128 f; // expected-error {{__float128 is not supported on this target}}
// But this should work:
template<typename> struct __is_floating_point_helper {};
-template<> struct __is_floating_point_helper<__float128> {};
+template<> struct __is_floating_point_helper<__float128> {}; // expected-error {{__float128 is not supported on this target}}
// FIXME: This could have a better diag.
-void g(int x, __float128 *y) {
- x + *y; // expected-error {{invalid operands to binary expression ('int' and '__float128')}}
+int g(int x, __float128 *y) { // expected-error {{__float128 is not supported on this target}}
+ return x + *y;
}
#else
-__float128 f; // expected-error {{unknown type name '__float128'}}
+__float128 f; // expected-error {{__float128 is not supported on this target}}
template<typename> struct __is_floating_point_helper {};
-template<> struct __is_floating_point_helper<__float128> {}; // expected-error {{use of undeclared identifier '__float128'}}
+template<> struct __is_floating_point_helper<__float128> {}; // expected-error {{__float128 is not supported on this target}}
-void g(int x, __float128 *y) { // expected-error {{unknown type name '__float128'}}
- x + *y;
+int g(int x, __float128 *y) { // expected-error {{__float128 is not supported on this target}}
+ return x + *y;
}
#endif
diff --git a/clang/test/Sema/float128-ld-incompatibility.cpp b/clang/test/Sema/float128-ld-incompatibility.cpp
new file mode 100644
index 00000000000..d993ed7b081
--- /dev/null
+++ b/clang/test/Sema/float128-ld-incompatibility.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple powerpc64le-unknown-linux-gnu -target-cpu pwr8 \
+// RUN: -target-feature +float128 %s
+
+__float128 qf();
+long double ldf();
+
+// 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'}}
+__float128 q{ldf()}; // expected-error {{cannot initialize a variable of type '__float128' with an rvalue of type 'long double'}}
+
+auto test1(__float128 q, long double ld) -> decltype(q + ld) { // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+ return q + ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+}
+
+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')}}
+}
+
+void test3(bool b) {
+ long double ld;
+ __float128 q;
+
+ ld + q; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
+ q + ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+ ld - q; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
+ q - ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+ ld * q; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
+ q * ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+ ld / q; // expected-error {{invalid operands to binary expression ('long double' and '__float128')}}
+ q / ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+ ld = q; // expected-error {{assigning to 'long double' from incompatible type '__float128'}}
+ q = ld; // expected-error {{assigning to '__float128' from incompatible type 'long double'}}
+ q + b ? q : ld; // expected-error {{incompatible operand types ('__float128' and 'long double')}}
+}
OpenPOWER on IntegriCloud