diff --git a/clang/lib/Headers/float.h b/clang/lib/Headers/float.h --- a/clang/lib/Headers/float.h +++ b/clang/lib/Headers/float.h @@ -14,11 +14,11 @@ * additional definitions provided for Windows. * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx * - * Also fall back on Darwin to allow additional definitions and + * Also fall back on Darwin and AIX to allow additional definitions and * implementation-defined values. */ -#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \ - __STDC_HOSTED__ && __has_include_next() +#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) || \ + defined(_AIX) && __STDC_HOSTED__ && __has_include_next() /* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level * of #include_next to keep Metrowerks compilers happy. Avoid this @@ -37,7 +37,8 @@ # undef FLT_MANT_DIG # undef DBL_MANT_DIG # undef LDBL_MANT_DIG -# if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 201103L +#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || \ + __cplusplus >= 201103L || defined(_AIX) && defined(_ALL_SOURCE) # undef DECIMAL_DIG # endif # undef FLT_DIG @@ -64,7 +65,8 @@ # undef FLT_MIN # undef DBL_MIN # undef LDBL_MIN -# if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 201703L +#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || \ + __cplusplus >= 201703L || defined(_AIX) && defined(_ALL_SOURCE) # undef FLT_TRUE_MIN # undef DBL_TRUE_MIN # undef LDBL_TRUE_MIN @@ -87,7 +89,8 @@ #define DBL_MANT_DIG __DBL_MANT_DIG__ #define LDBL_MANT_DIG __LDBL_MANT_DIG__ -#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 201103L +#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || \ + __cplusplus >= 201103L || defined(_AIX) && defined(_ALL_SOURCE) # define DECIMAL_DIG __DECIMAL_DIG__ #endif @@ -123,7 +126,8 @@ #define DBL_MIN __DBL_MIN__ #define LDBL_MIN __LDBL_MIN__ -#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 201703L +#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || \ + __cplusplus >= 201703L || defined(_AIX) && defined(_ALL_SOURCE) # define FLT_TRUE_MIN __FLT_DENORM_MIN__ # define DBL_TRUE_MIN __DBL_DENORM_MIN__ # define LDBL_TRUE_MIN __LDBL_DENORM_MIN__ diff --git a/clang/test/Headers/float.c b/clang/test/Headers/float.c --- a/clang/test/Headers/float.c +++ b/clang/test/Headers/float.c @@ -4,6 +4,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++11 -ffreestanding %s // RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++14 -ffreestanding %s // RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++17 -ffreestanding %s +// RUN: %clang_cc1 -triple powerpc-ibm-aix -fsyntax-only -verify -std=c99 -ffreestanding -D_ALL_SOURCE %s // expected-no-diagnostics /* Basic floating point conformance checks against: @@ -45,7 +46,8 @@ #endif -#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 201703L +#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || \ + __cplusplus >= 201703L || defined(_AIX) && defined(_ALL_SOURCE) #ifndef FLT_DECIMAL_DIG #error "Mandatory macro FLT_DECIMAL_DIG is missing." #elif FLT_DECIMAL_DIG < 6 @@ -101,7 +103,8 @@ #endif -#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 201103L +#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || \ + __cplusplus >= 201103L || defined(_AIX) && defined(_ALL_SOURCE) #ifndef DECIMAL_DIG #error "Mandatory macro DECIMAL_DIG is missing." #elif DECIMAL_DIG < 10 @@ -215,13 +218,15 @@ _Static_assert(DBL_MANT_DIG == __DBL_MANT_DIG__, ""); _Static_assert(LDBL_MANT_DIG == __LDBL_MANT_DIG__, ""); -#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 201703L +#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || \ + __cplusplus >= 201703L || defined(_AIX) && defined(_ALL_SOURCE) _Static_assert(FLT_DECIMAL_DIG == __FLT_DECIMAL_DIG__, ""); _Static_assert(DBL_DECIMAL_DIG == __DBL_DECIMAL_DIG__, ""); _Static_assert(LDBL_DECIMAL_DIG == __LDBL_DECIMAL_DIG__, ""); #endif -#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 201103L +#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || \ + __cplusplus >= 201103L || defined(_AIX) && defined(_ALL_SOURCE) _Static_assert(DECIMAL_DIG == __DECIMAL_DIG__, ""); #endif