From: Bruno Cardoso Lopes Date: Thu, 8 Dec 2016 02:13:56 +0000 (+0000) Subject: [Headers] Enable #include_next on Darwin X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f5457ae5ebdeb012f213018a46dfea196ea1a872;p=clang [Headers] Enable #include_next on Darwin Allows darwin targets to provide additional definitions and implementation specifc values for float.h rdar://problem/21961491 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289018 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Headers/float.h b/lib/Headers/float.h index a28269ebeb..0f453d87cb 100644 --- a/lib/Headers/float.h +++ b/lib/Headers/float.h @@ -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() +#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \ + __STDC_HOSTED__ && __has_include_next() # include_next /* Undefine anything that we'll be redefining below. */ diff --git a/test/Headers/Inputs/usr/include/float.h b/test/Headers/Inputs/usr/include/float.h new file mode 100644 index 0000000000..9dab891b97 --- /dev/null +++ b/test/Headers/Inputs/usr/include/float.h @@ -0,0 +1,6 @@ +#ifndef SYSFLOAT_H +#define SYSFLOAT_H + +#define FLT_HAS_SUBNORM 1 + +#endif /* SYSFLOAT_H */ diff --git a/test/Headers/float-darwin.c b/test/Headers/float-darwin.c new file mode 100644 index 0000000000..54bac1ac63 --- /dev/null +++ b/test/Headers/float-darwin.c @@ -0,0 +1,13 @@ +// REQUIRES: system-darwin +// RUN: %clang -target x86_64-apple-darwin10 -fsyntax-only -std=c11 -isysroot %S/Inputs %s +#include + +// 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