<float.h>: do not define DECIMAL_DIG in -std=c89 mode; this macro was added in C99.

Patch by Jorge Teixeira!

llvm-svn: 260639
This commit is contained in:
Richard Smith 2016-02-12 01:15:33 +00:00
parent e8178e8e8f
commit 66a7385e27
2 changed files with 26 additions and 8 deletions
clang
lib/Headers
test/Headers

View File

@ -39,7 +39,9 @@
# undef FLT_MANT_DIG
# undef DBL_MANT_DIG
# undef LDBL_MANT_DIG
# undef DECIMAL_DIG
# if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
# undef DECIMAL_DIG
# endif
# undef FLT_DIG
# undef DBL_DIG
# undef LDBL_DIG
@ -84,7 +86,9 @@
#define DBL_MANT_DIG __DBL_MANT_DIG__
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
#define DECIMAL_DIG __DECIMAL_DIG__
#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
# define DECIMAL_DIG __DECIMAL_DIG__
#endif
#define FLT_DIG __FLT_DIG__
#define DBL_DIG __DBL_DIG__

View File

@ -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__, "");