[clang] [Clang][Driver] Warn on complex number range incompatibility with GCC (PR #144468)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 23 10:09:03 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">,
----------------
AaronBallman wrote:
> I understand that it's better to emit a single warning message. In that case, how about simply adding the "specify" part to the end of the original warning message? At least I think users would understand what to do. `warning: combination of '-fcx-fortran-rules' and '-fcx-limited-range' results in complex number calculations incompatible with GCC. specify '-fcx-fortran-rules' after '-fcx-limited-range' for GCC compatibility [-Wgcc-compat] `
>
> However, this warning message might be redundant because it's long and displays the same option twice. It might be better to use the following instead: `warning: complex number calculation is incompatible with GCC. specify '-fcx-fortran-rules' after '-fcx-limited-range' for compatibility [-Wgcc-compat]`
The logic here might get a bit odd because one warning is `-Woverriding-option` and the second is `-Wgcc-compat`. So I think what we want is:
```
// -Wgcc-compat -Wno-overriding-option
warning: complex number calculation is incompatible with GCC; specify '-fcx-fortran-rules' after '-fcx-limited-range' for compatibility
// -Woverriding-option -Wno-gcc-compat
warning: overriding '-fcx-fortran-rules' option with '-fcx-limited-range'
// -Wgcc-compat -Woverriding-option
warning: overriding '-fcx-fortran-rules' option with '-fcx-limited-range' and is incompatible with GCC; specify '-fcx-fortran-rules' after '-fcx-limited-range' for compatibility
```
though I'm not certain how easy or hard that would be to implement.
https://github.com/llvm/llvm-project/pull/144468
More information about the cfe-commits
mailing list