Skip to content

Conversation

@ldionne
Copy link
Member

@ldionne ldionne commented Apr 9, 2024

As reported in #86843, we must have #pragma GCC system_header before we use #include_next, otherwise the compiler may not understand that we're in a system header and may issue a diagnostic for our usage of

As reported in llvm#86843, we must have #pragma GCC system_header before we use #include_next, otherwise the compiler may not understand that we're in a system header and may issue a diagnostic for our usage of
@ldionne ldionne requested a review from a team as a code owner April 9, 2024 23:49
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Apr 9, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 9, 2024

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

As reported in #86843, we must have #pragma GCC system_header before we use #include_next, otherwise the compiler may not understand that we're in a system header and may issue a diagnostic for our usage of


Full diff: https://github.com/llvm/llvm-project/pull/88214.diff

1 Files Affected:

  • (modified) libcxx/include/stddef.h (+4-4)
diff --git a/libcxx/include/stddef.h b/libcxx/include/stddef.h index 470b5408336c6d..1583e78e3739ba 100644 --- a/libcxx/include/stddef.h +++ b/libcxx/include/stddef.h @@ -26,6 +26,10 @@ #include <__config> +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + // Note: This include is outside of header guards because we sometimes get included multiple times // with different defines and the underlying <stddef.h> will know how to deal with that. #include_next <stddef.h> @@ -33,10 +37,6 @@ #ifndef _LIBCPP_STDDEF_H # define _LIBCPP_STDDEF_H -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif - # ifdef __cplusplus typedef decltype(nullptr) nullptr_t; # endif 
Copy link
Member

@mordante mordante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I did a spot check of our headers and this seems a one off, so I don't think we need to add comments to the location of pragma GCC system_header.

@ian-twilightcoder
Copy link
Contributor

@ldionne like @nico said, we merged the original change to llvm 18 so now we need this one too. 🙄

@nico nico merged commit 3c4b673 into llvm:main Apr 11, 2024
@nico
Copy link
Contributor

nico commented Apr 11, 2024

@ian-twilightcoder Do you want to create the merge ticket?

@ldionne ldionne deleted the review/fix-include-next branch April 11, 2024 17:48
@ldionne ldionne added this to the LLVM 18.X Release milestone Apr 11, 2024
@ldionne
Copy link
Member Author

ldionne commented Apr 11, 2024

/cherry-pick 3c4b673

llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request Apr 11, 2024
As reported in llvm#86843, we must have #pragma GCC system_header before we use #include_next, otherwise the compiler may not understand that we're in a system header and may issue a diagnostic for our usage of (cherry picked from commit 3c4b673)
@llvmbot
Copy link
Member

llvmbot commented Apr 11, 2024

/pull-request #88419

llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request Apr 11, 2024
As reported in llvm#86843, we must have #pragma GCC system_header before we use #include_next, otherwise the compiler may not understand that we're in a system header and may issue a diagnostic for our usage of (cherry picked from commit 3c4b673)
tstellar pushed a commit to llvmbot/llvm-project that referenced this pull request Apr 16, 2024
As reported in llvm#86843, we must have #pragma GCC system_header before we use #include_next, otherwise the compiler may not understand that we're in a system header and may issue a diagnostic for our usage of (cherry picked from commit 3c4b673)
@pointhex pointhex mentioned this pull request May 7, 2024
Tedlion pushed a commit to Tedlion/llvm-project that referenced this pull request Jun 15, 2025
As reported in llvm#86843, we must have #pragma GCC system_header before we use #include_next, otherwise the compiler may not understand that we're in a system header and may issue a diagnostic for our usage of (cherry picked from commit 3c4b673)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

5 participants