From d93779da151a46532353c07b704b8e569ed1c81a Mon Sep 17 00:00:00 2001 From: Bruno Cardoso Lopes Date: Thu, 8 Dec 2016 02:13:56 +0000 Subject: [Headers] Enable #include_next on Darwin Allows darwin targets to provide additional definitions and implementation specifc values for float.h rdar://problem/21961491 llvm-svn: 289018 --- clang/lib/Headers/float.h | 7 +++++-- clang/test/Headers/Inputs/usr/include/float.h | 6 ++++++ clang/test/Headers/float-darwin.c | 13 +++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 clang/test/Headers/Inputs/usr/include/float.h create mode 100644 clang/test/Headers/float-darwin.c (limited to 'clang') diff --git a/clang/lib/Headers/float.h b/clang/lib/Headers/float.h index a28269ebebb..0f453d87cbc 100644 --- a/clang/lib/Headers/float.h +++ b/clang/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/clang/test/Headers/Inputs/usr/include/float.h b/clang/test/Headers/Inputs/usr/include/float.h new file mode 100644 index 00000000000..9dab891b972 --- /dev/null +++ b/clang/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/clang/test/Headers/float-darwin.c b/clang/test/Headers/float-darwin.c new file mode 100644 index 00000000000..54bac1ac630 --- /dev/null +++ b/clang/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 -- cgit v1.2.3