[libc++] PR25118: move include_next after #pragma system_header

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 8 16:36:24 PDT 2015


Hi,

As noted in PR25118, people who include libc++'s headers via a -I path with
-pedantic_errors will see errors due to the use of #include_next. This
patch moves the #include_next after the #pragma system_header line to
suppress the error.

(For the __need_* case in <stddef.h>, I'm not checking whether pragma
system_header is available: these macros should only be defined for systems
where the pragma is available, and it doesn't seem like a good idea to
include <__config> in this case.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151008/fb93e846/attachment.html>
-------------- next part --------------
Index: complex.h
===================================================================
--- complex.h	(revision 249736)
+++ complex.h	(working copy)
@@ -18,6 +18,12 @@
 
 */
 
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 #ifdef __cplusplus
 
 #include <ccomplex>
@@ -28,8 +34,4 @@
 
 #endif  // __cplusplus
 
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
 #endif  // _LIBCPP_COMPLEX_H
Index: cstddef
===================================================================
--- cstddef	(revision 249761)
+++ cstddef	(working copy)
@@ -34,14 +34,15 @@
 */
 
 #include <__config>
-// Don't include our own <stddef.h>; we don't want to declare ::nullptr_t.
-#include_next <stddef.h>
-#include <__nullptr>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+// Don't include our own <stddef.h>; we don't want to declare ::nullptr_t.
+#include_next <stddef.h>
+#include <__nullptr>
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::ptrdiff_t;
Index: ctype.h
===================================================================
--- ctype.h	(revision 249738)
+++ ctype.h	(working copy)
@@ -31,12 +31,13 @@
 */
 
 #include <__config>
-#include_next <ctype.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next <ctype.h>
+
 #ifdef __cplusplus
 
 #if defined(_LIBCPP_MSVCRT)
Index: errno.h
===================================================================
--- errno.h	(revision 249739)
+++ errno.h	(working copy)
@@ -24,12 +24,13 @@
 */
 
 #include <__config>
-#include_next <errno.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next <errno.h>
+
 #if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
 
 #ifdef ELAST
Index: float.h
===================================================================
--- float.h	(revision 249740)
+++ float.h	(working copy)
@@ -61,12 +61,13 @@
 */
 
 #include <__config>
-#include_next <float.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next <float.h>
+
 #ifndef FLT_EVAL_METHOD
 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
 #endif
Index: inttypes.h
===================================================================
--- inttypes.h	(revision 249741)
+++ inttypes.h	(working copy)
@@ -232,12 +232,13 @@
 */
 
 #include <__config>
-#include_next <inttypes.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next <inttypes.h>
+
 #ifdef __cplusplus
 
 #include <stdint.h>
Index: math.h
===================================================================
--- math.h	(revision 249742)
+++ math.h	(working copy)
@@ -293,12 +293,13 @@
 */
 
 #include <__config>
-#include_next <math.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next <math.h>
+
 #ifdef __cplusplus
 
 // We support including .h headers inside 'extern "C"' contexts, so switch
Index: setjmp.h
===================================================================
--- setjmp.h	(revision 249743)
+++ setjmp.h	(working copy)
@@ -27,12 +27,13 @@
 */
 
 #include <__config>
-#include_next <setjmp.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next <setjmp.h>
+
 #ifndef setjmp
 #define setjmp(env) setjmp(env)
 #endif
Index: stddef.h
===================================================================
--- stddef.h	(revision 249761)
+++ stddef.h	(working copy)
@@ -10,6 +10,8 @@
 
 #if defined(__need_ptrdiff_t) || defined(__need_size_t) || \
     defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t)
+
+#pragma GCC system_header
 #include_next <stddef.h>
 
 #elif !defined(_LIBCPP_STDDEF_H)
@@ -33,12 +35,13 @@
 */
 
 #include <__config>
-#include_next <stddef.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
+#include_next <stddef.h>
+
 #ifdef __cplusplus
 
 extern "C++" {


More information about the cfe-commits mailing list