[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
Tue Jul 29 02:18:58 PDT 2025


s-watanabe314 wrote:

The implementation would become complex and it would be difficult to accurately track GCC, so I will stop trying to output warnings about incompatibility with GCC. However, there is a problem that the warning message when a complex range is overridden displays options that the user has not explicitly specified. Should we at least fix this?

I believe a new warning message should be issued when the following options change the value of the complex range:

- -f[no-]cx-limited-range
- -f[no-]cx-fortran-rules
- -fcomplex-arithmetic=[ full | improved | promoted | basic ]
- -ffp-model=[ strict | precise | fast | aggressive ]
- -f[no-]fast-math

Current warning message:
```
$ clang foo.c -ffp-model=fast -fcx-fortran-rules -###
clang: warning: overriding '-complex-range=promoted' option with '-fcx-fortran-rules' [-Woverriding-option]
```
Example of a new warning message:
```
$ clang foo.c -ffp-model=fast -fcx-fortran-rules -###
clang: warning: '-fcx-fortran-rules' sets complex range to "improved" overriding the setting of "promoted" that was implied by '-ffp-model=fast' [-Woverriding-option]
```
However, no warning should be issued for the following combinations:
```
//  Do not emit a warning if NewOpt overrides LastOpt in the following cases.
//
// | LastOpt               | NewOpt                |
// |-----------------------|-----------------------|
// | -fcx-limited-range    | -fno-cx-limited-range |
// | -fno-cx-limited-range | -fcx-limited-range    |
// | -fcx-fortran-rules    | -fno-cx-fortran-rules |
// | -fno-cx-fortran-rules | -fcx-fortran-rules    |
// | -ffast-math           | -fno-fast-math        |
// | -ffp-model=           | -fno-fast-math        |
// | -ffp-model=           | -ffp-model=           |
// | -fcomplex-arithmetic= | -fcomplex-arithmetic= |
```

https://github.com/llvm/llvm-project/pull/149028


More information about the cfe-commits mailing list