[cfe-dev] -pedantic warnings in system headers?

Stephan Bergmann via cfe-dev cfe-dev at lists.llvm.org
Tue Jul 18 08:06:40 PDT 2017


On 07/14/2017 08:13 PM, David Blaikie wrote:
> On Thu, Jul 13, 2017 at 9:18 AM David Chisnall via cfe-dev 
> <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
> 
>     On 13 Jul 2017, at 17:07, Stephan Bergmann via cfe-dev
>     <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
>      >
>      > From a quick look at the code of both GCC and Clang, I assume the
>     difference is due to GCC implicitly assuming /usr/include/assert.h
>     to be a system header (so it suppresses the pedantic warning there),
>     while Clang does not.  (Curiously, while many of the libstdc++ files
>     in /usr/include/c++/... have
> 
>     I believe that this is a known issue, where the warning suppression
>     for macros happens based on the instantiation location, not on the
>     declaration location.  You are getting the warning because the file
>     in which you instantiate the macro is not a system header, even
>     though the macro is defined in a system header.
> 
> Not always the case - Clang looks at where a macro is defined in many 
> cases, I think - though I could be wrong. Maybe this one hasn't been 
> adjusted yet.

I've come up with <https://reviews.llvm.org/D35564> "Suppress -pedantic 
warnings about GNU extension StmtExpr in glibc's assert macro".  Reviews 
welcome.



More information about the cfe-dev mailing list