r289018 - [Headers] Enable #include_next<float.h> on Darwin

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 7 18:13:57 PST 2016


Author: bruno
Date: Wed Dec  7 20:13:56 2016
New Revision: 289018

URL: http://llvm.org/viewvc/llvm-project?rev=289018&view=rev
Log:
[Headers] Enable #include_next<float.h> on Darwin

Allows darwin targets to provide additional definitions and
implementation specifc values for float.h

rdar://problem/21961491

Added:
    cfe/trunk/test/Headers/Inputs/usr/
    cfe/trunk/test/Headers/Inputs/usr/include/
    cfe/trunk/test/Headers/Inputs/usr/include/float.h
    cfe/trunk/test/Headers/float-darwin.c
Modified:
    cfe/trunk/lib/Headers/float.h

Modified: cfe/trunk/lib/Headers/float.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/float.h?rev=289018&r1=289017&r2=289018&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/float.h (original)
+++ cfe/trunk/lib/Headers/float.h Wed Dec  7 20:13:56 2016
@@ -27,9 +27,12 @@
 /* If we're on MinGW, fall back to the system's float.h, which might have
  * 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
+ * implementation-defined values.
  */
-#if (defined(__MINGW32__) || defined(_MSC_VER)) && __STDC_HOSTED__ && \
-    __has_include_next(<float.h>)
+#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
+    __STDC_HOSTED__ && __has_include_next(<float.h>)
 #  include_next <float.h>
 
 /* Undefine anything that we'll be redefining below. */

Added: cfe/trunk/test/Headers/Inputs/usr/include/float.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/Inputs/usr/include/float.h?rev=289018&view=auto
==============================================================================
--- cfe/trunk/test/Headers/Inputs/usr/include/float.h (added)
+++ cfe/trunk/test/Headers/Inputs/usr/include/float.h Wed Dec  7 20:13:56 2016
@@ -0,0 +1,6 @@
+#ifndef SYSFLOAT_H
+#define SYSFLOAT_H
+
+#define FLT_HAS_SUBNORM 1
+
+#endif /* SYSFLOAT_H */

Added: cfe/trunk/test/Headers/float-darwin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/float-darwin.c?rev=289018&view=auto
==============================================================================
--- cfe/trunk/test/Headers/float-darwin.c (added)
+++ cfe/trunk/test/Headers/float-darwin.c Wed Dec  7 20:13:56 2016
@@ -0,0 +1,13 @@
+// REQUIRES: system-darwin
+// RUN: %clang -target x86_64-apple-darwin10 -fsyntax-only -std=c11 -isysroot %S/Inputs %s
+#include <float.h>
+
+// Test the #include_next on float.h works on Darwin.
+#ifndef FLT_HAS_SUBNORM
+  #error "FLT_HAS_SUBNORM not defined"
+#endif
+
+// Test that definition from builtin are also present.
+#ifndef FLT_MAX
+  #error "FLT_MAX not defined"
+#endif




More information about the cfe-commits mailing list