[clang] [clang][driver] Improve warning message for complex range overrides and GCC incompatibility (PR #149028)
Shunsuke Watanabe via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 25 02:32:46 PDT 2025
s-watanabe314 wrote:
> I'm not sure the combined warning is necessary. I think just stating that the clang option overrides the GCC option is sufficient since there is no sense in which clang-specific options can be incompatible with GCC if GCC doesn't implement the option.
In this patch, when clang-specific options and GCC options are combined, only the override warning is output. The combined warning is output when a GCC option overrides another GCC option. Specifically, there are the following seven cases described in `range-warnings.c`:
```
// Case B: GCC Incompatibility Warnings
// Emit warnings because the following cases result in behavior
// incompatible with GCC:
// (a) -fcx-limited-range -fno-fast-math
// (b) -fcx-fortran-rules -fcx-limited-range
// (c) -fcx-fortran-rules -fno-cx-limited-range
// (d) -fcx-fortran-rules -ffast-math
// (e) -fcx-fortran-rules -fno-fast-math
// (f) -fno-cx-fortran-rules -fcx-limited-range
// (g) -fno-cx-fortran-rules -ffast-math
// Case C: Combined A and B Warnings
// Emit combined warnings when both A and B apply. This is the default
// warning when both apply. The warning message changes to Case A or B
// if the user specifies -Wno-gcc-compat or -Wno-overriding-complex-range.
```
In these cases, an override occurs and also an incompatibility with GCC, so I believe a different warning should be output.
> I think we're all in agreement that we want to consistently follow "last command wins" behavior, even when GCC doesn't. This patch isn't changing that, right?
Yes, this patch only changes the warnings and does not change the "last-flag-wins" behavior.
https://github.com/llvm/llvm-project/pull/149028
More information about the cfe-commits
mailing list