[clang] [clang] Assert the enum FPOpts and LangOpts fit into the storage (PR #126166)

Zahira Ammarguellat via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 10 05:25:56 PST 2025


zahiraam wrote:

> @zahiraam the default of the `ComplexRange`, `CX_None` does overflow the `2` storage bits. That means we were probably still using `CX_Full` (4 should overflow to `0`) even after #78330 (I am not sure why why that changed the default in the first place). Also it's impossible to manually choose `CX_None`.

The only valid values for  the `-fcomplex-arithmetic` option are: `CX_Full`, `CX_Improved`, `CX_Promoted` and `CX_Basic`. 
Using `clang.exe -fcomplex-arithmetic=none t.c` would lead to this error:
`clang: error: unsupported argument 'none' to option '-fcomplex-arithmetic='`
So `2` bits of storage is enough for `ComplexRange`. `ComplexRange` values can only be 4 values above.
The value `CX_None` is the defaut value given to the `Range` when no `fcomplex-arithmetic` is used on the command line. https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Clang.cpp#L2989 but it's not a valid option for `fcomplex-arithmetic`.

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


More information about the cfe-commits mailing list