[clang] [Clang][Driver] Override complex number calculation method by -fno-fa… (PR #132680)

via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 3 03:52:08 PDT 2025


s-watanabe314 wrote:

> I would like to see warnings for -fno-fast-math overriding explicit complex range options, especially since GCC doesn't do that.


Is "explicit complex range options" referring to the `-fcomplex-arithmetic=` and GCC options? If so, when `-fno-fast-math` overrides other options, should I modify the behavior as follows?

- Issue a warning when `-fno-fast-math` overrides explicit options.

|Option|Warning|
|-|-|
|-fcx-limited-range -fno-fast-math|warning: overriding '-fcx-limited-range' option with '-fno-fast-math'|
|-fcx-fortran-rules -fno-fast-math|warning: overriding '-fcx-fortran-rules' option with '-fno-fast-math'|
|-fcomplex-arithmetic=basic -fno-fast-math|warning: overriding '-fcomplex-arithmetic=basic' option with '-fno-fast-math'|

- Do not issue a warning when overriding non-explicit options.

|Option|Warning|
|-|-|
|-ffast-math -fno-fast-math|No warning|
|-ffp-model=aggressive -fno-fast-math|No warning|


Furthermore, if `-fno-fast-math` means that it resets the state to the default, is a warning always unnecessary if another option is specified after `-fno-fast-math`? To implement this, I think we can assign `CX_None` to `Range` instead of `CX_Full` when the `-fno-fast-math` is specified.

- All of the following examples do not issue a warning:

|Option|Warning|
|-|-|
|-fno-fast-math -fcx-limited-range|No warning|
|-fno-fast-math -fcx-fortran-rules|No warning|
|-fno-fast-math -fcomplex-arithmetic=basic|No warning|
|-fno-fast-math -ffp-model=aggressive|No warning|

> This may contradict things I've said earlier, but it doesn't seem like we should treat the GCC options differently than the clang-specific options with regard to whether or not we issue warnings. Also, the warnings are referencing options that the user didn't explicitly specify.


I agree that we shouldn't treat them differently. `GccRangeComplexOption` is only used to determine whether to issue a warning. I'm considering replacing it with `LastComplexRangeOption`. This would allow the warning message to directly reference the user-specified option.

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


More information about the cfe-commits mailing list