aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/dfp/pragma-float-const-decimal64-7.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/dfp/pragma-float-const-decimal64-7.c')
-rw-r--r--gcc/testsuite/gcc.dg/dfp/pragma-float-const-decimal64-7.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/dfp/pragma-float-const-decimal64-7.c b/gcc/testsuite/gcc.dg/dfp/pragma-float-const-decimal64-7.c
new file mode 100644
index 00000000000..7533ee7f0de
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dfp/pragma-float-const-decimal64-7.c
@@ -0,0 +1,39 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wall" } */
+
+/* N1312 7.1.1: The FLOAT_CONST_DECIMAL64 pragma.
+ C99 6.4.4.2a (New).
+
+ Check that when pragma FLOAT_CONST_DECIMAL64 is in effect so that
+ unsuffixed constants are _Decimal64, invalid types are still reported
+ as invalid. */
+
+double
+f1 (void)
+{
+#pragma STDC FLOAT_CONST_DECIMAL64 OFF
+ double a = 0x1.0p1;
+ double b = 1.0i;
+
+ return a + b;
+}
+
+double
+f2 (void)
+{
+#pragma STDC FLOAT_CONST_DECIMAL64 OFF
+ double a = 0x1.0p1dd; /* { dg-error "with hex" } */
+ double b = 1.0idd; /* { dg-error "invalid suffix" } */
+
+ return a + b;
+}
+
+double
+f3 (void)
+{
+#pragma STDC FLOAT_CONST_DECIMAL64 ON
+ double a = 0x1.0p1; /* Hex constant is not affected by pragma. */
+ double b = 1.0i; /* Imaginary constant is not affected by pragma. */
+
+ return a + b;
+}