[clang] 27ee911 - [AIX][clang] include_next through clang provided float.h

David Tenty via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 28 10:27:35 PST 2022


Author: David Tenty
Date: 2022-01-28T13:27:10-05:00
New Revision: 27ee91162dd3f01d692e8f092903dd79f4e54348

URL: https://github.com/llvm/llvm-project/commit/27ee91162dd3f01d692e8f092903dd79f4e54348
DIFF: https://github.com/llvm/llvm-project/commit/27ee91162dd3f01d692e8f092903dd79f4e54348.diff

LOG: [AIX][clang] include_next through clang provided float.h

AIX provides additional definitions in the system libc float.h that we
would like to be available to users, so we need to include_next through,
similar to what is done on some other platforms.

We also adjust the guards for some definitions which are restricted
based on language level to also be provide with the _ALL_SOURCE feature
test macro on AIX, similar to what is done by the platform float.h
header, so we don't run into cases where we don't provide the compiler
macro but still have a different definition from the system.

Differential Revision: https://reviews.llvm.org/D117935

Added: 
    clang/test/Headers/Inputs/include/float.h
    clang/test/Headers/float-aix.c

Modified: 
    clang/lib/Headers/float.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/float.h b/clang/lib/Headers/float.h
index ed610b24aa103..c6a6cc08462da 100644
--- a/clang/lib/Headers/float.h
+++ b/clang/lib/Headers/float.h
@@ -14,10 +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))) && \
+#if (defined(__APPLE__) || defined(__MINGW32__) || defined(_MSC_VER) ||        \
+     defined(_AIX)) &&                                                         \
     __STDC_HOSTED__ && __has_include_next(<float.h>)
 
 /* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level
@@ -37,7 +38,9 @@
 #  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 ||                                                \
+      (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #    undef DECIMAL_DIG
 #  endif
 #  undef FLT_DIG
@@ -64,7 +67,9 @@
 #  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 ||                                                \
+      (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #    undef FLT_TRUE_MIN
 #    undef DBL_TRUE_MIN
 #    undef LDBL_TRUE_MIN
@@ -87,7 +92,9 @@
 #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 ||                                                  \
+    (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
 #  define DECIMAL_DIG __DECIMAL_DIG__
 #endif
 
@@ -123,7 +130,9 @@
 #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 ||                                                  \
+    (__STDC_HOSTED__ && 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/Inputs/include/float.h b/clang/test/Headers/Inputs/include/float.h
new file mode 100644
index 0000000000000..616a02c9c95c9
--- /dev/null
+++ b/clang/test/Headers/Inputs/include/float.h
@@ -0,0 +1,2 @@
+#pragma once
+#define FLOAT_LOCAL_DEF 1

diff  --git a/clang/test/Headers/float-aix.c b/clang/test/Headers/float-aix.c
new file mode 100644
index 0000000000000..d43eae79bcd17
--- /dev/null
+++ b/clang/test/Headers/float-aix.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -fsyntax-only -verify -internal-isystem %S/Inputs/include %s
+// expected-no-diagnostics
+
+#include <float.h>
+
+_Static_assert(FLOAT_LOCAL_DEF, "");


        


More information about the cfe-commits mailing list