Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang -Wunknown-pragmas shouldn't warn about a '#pragma GCC diagnostic' it doesn't know #25435

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR25436
Status CONFIRMED
Importance P normal
Reported by Sean McBride (sean@rogue-research.com)
Reported on 2015-11-06 15:48:15 -0800
Last modified on 2020-04-17 18:33:35 -0700
Version trunk
Hardware All All
CC bmoses@google.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk, rtrieu@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also PR10623
If clang r252202 encounters this:

#pragma GCC diagnostic ignored "-Wlarger-than="

it warns:

test.c:1:32: warning: unknown warning group '-Wlarger-than=', ignored [-
Wunknown-pragmas]
#pragma GCC diagnostic ignored "-Wlarger-than="
                               ^

GCC has a -Wlarger-than= warning, clang does not (itself bug #10623).

I realize I'm sorta asking for such warnings by specifying -Wunknown-pragmas,
but I think this is a bit different.  Ordinarily, I would guard
complier/platform-specific pragmas with something like:

#if __GNUC__

but that won't help because clang (incompletely) pretends to be GCC.  (And -
Wlarger-than= is in gcc 4.2, so adding version checks won't help.)

I guess the only workaround for portable code is something like:

#if __GNUC__ && !__clang__

Basically, I see little value in -Wunknown-pragmas warning that clang's GCC
emulation is not 100%.  Perhaps a special case for "#pragma GCC"?  Or whitelist
known GCC warning flags that clang doesn't support?
Quuxplusone commented 5 years ago

Just a note to say issue still occurs with trunk 347180.

Interestingly, if one passes "-Wlarger-than=3000" to clang it doesn't complain that the flag is unknown (for gcc compatibility no doubt), so why inconsistently complain in the pragma case?

Quuxplusone commented 4 years ago
This is still happening with trunk, although now it blames the warning on -
Wunknown-warning-option (at least in my case).

This is preventing us from compiling NumPY with -Wunknown-warning-option turned
on, because of this line:
https://github.com/numpy/numpy/blob/master/numpy/linalg/umath_linalg.c.src#L734

numpy/linalg/umath_linalg.c.src:744:32: error: unknown warning group '-Wmaybe-
uninitialized', ignored [-Werror,-Wunknown-warning-option]
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
                               ^
1 error generated.