summaryrefslogtreecommitdiffstats
path: root/test/Headers
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-02-12 01:15:33 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-02-12 01:15:33 +0000
commitd14e35f115c7e253d25928e671411766f0f3fc76 (patch)
tree33ef4f5d0a7baf1083689f488ecbc9957c800bbb /test/Headers
parent25e062e55e631aafc84fd27cc9580d0065096c02 (diff)
<float.h>: do not define DECIMAL_DIG in -std=c89 mode; this macro was added in C99.
Patch by Jorge Teixeira! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260639 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Headers')
-rw-r--r--test/Headers/float.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/test/Headers/float.c b/test/Headers/float.c
index f492531f39..32249d1d46 100644
--- a/test/Headers/float.c
+++ b/test/Headers/float.c
@@ -3,9 +3,15 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
// expected-no-diagnostics
-/* Basic conformance checks against the N1570 draft of C11 Std. */
+/* Basic floating point conformance checks against:
+ - N1570 draft of C11 Std.
+ - N1256 draft of C99 Std.
+ - http://port70.net/~nsz/c/c89/c89-draft.html draft of C89/C90 Std.
+*/
/*
- 5.2.4.2.2p11, pp. 30
+ C11, 5.2.4.2.2p11, pp. 30
+ C99, 5.2.4.2.2p9, pp. 25
+ C89, 2.2.4.2
*/
#include <float.h>
@@ -68,10 +74,16 @@
#endif
-#ifndef DECIMAL_DIG
- #error "Mandatory macro DECIMAL_DIG is missing."
-#elif DECIMAL_DIG < 10
- #error "Mandatory macro DECIMAL_DIG is invalid."
+#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
+ #ifndef DECIMAL_DIG
+ #error "Mandatory macro DECIMAL_DIG is missing."
+ #elif DECIMAL_DIG < 10
+ #error "Mandatory macro DECIMAL_DIG is invalid."
+ #endif
+#else
+ #ifdef DECIMAL_DIG
+ #error "Macro DECIMAL_DIG should not be defined."
+ #endif
#endif
@@ -182,7 +194,9 @@ _Static_assert(DBL_DECIMAL_DIG == __DBL_DECIMAL_DIG__, "");
_Static_assert(LDBL_DECIMAL_DIG == __LDBL_DECIMAL_DIG__, "");
#endif
+#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
_Static_assert(DECIMAL_DIG == __DECIMAL_DIG__, "");
+#endif
_Static_assert(FLT_DIG == __FLT_DIG__, "");
_Static_assert(DBL_DIG == __DBL_DIG__, "");