[clang] [Clang][Driver] Warn on complex number range incompatibility with GCC (PR #144468)
Shunsuke Watanabe via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 27 02:21:49 PDT 2025
================
@@ -520,6 +520,9 @@ def warn_drv_math_errno_enabled_after_veclib: Warning<
"math errno enabled by '%0' after it was implicitly disabled by '%1',"
" this may limit the utilization of the vector library">,
InGroup<MathErrnoEnabledWithVecLib>;
+def warn_drv_gcc_incompatible_complex_range_override: Warning<
+ "combination of '%0' and '%1' results in complex number calculations incompatible with GCC">,
----------------
s-watanabe314 wrote:
> IIRC, you can do that by adding an explicit compiler option for it, like:
That method seems implementable. Thank you!
However, I'm concerned that the warning message about the `-ffast-math` override is being output with an option name that the user didn't specify. For example:
```
$ clang -fcx-fortran-rules -ffast-math
clang: warning: overriding '-fcx-fortran-rules' option with '-fcomplex-arithmetic=basic' [-Woverriding-option]
$ clang -fno-cx-fortran-rules -ffast-math
clang: warning: overriding '-fno-cx-fortran-rules' option with '-fcomplex-arithmetic=basic' [-Woverriding-option]
```
If we were to output `-Wgcc-compat` in conjunction with these, what should the warning message look like? For example, should it output the option name that the user specified, like this?
```
$ clang -fcx-fortran-rules -ffast-math -Wgcc-compat -Wno-overriding-option
warning: complex number calculation is incompatible with GCC; specify '-ffast-math' after '-fcx-fortran-rules' for compatibility
$ clang -fcx-fortran-rules -ffast-math -Woverriding-option -Wno-gcc-compat
warning: overriding '-fcx-fortran-rules' option with '-ffast-math'
$ clang -fcx-fortran-rules -ffast-math -Wgcc-compat -Woverriding-option
warning: overriding '-fcx-fortran-rules' option with '-ffast-math' and is incompatible with GCC; specify '-ffast-math' after '-fcx-fortran-rules' for compatibility
```
To achieve this, it might be necessary to first fix the behavior where the override warning messages for `-ffast-math` and `-ffp-model=` are output with option names that the user didn't specify.
https://github.com/llvm/llvm-project/pull/144468
More information about the cfe-commits
mailing list