[clang] [clang][Interp] Handle complex values in visitBool() (PR #79452)

via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 19 08:02:13 PST 2024


================
@@ -125,3 +125,7 @@ struct XY { int before; struct XX xx, *xp; float* after; } xy[] = {
   0,              // all-warning {{initializer overrides prior initialization of this subobject}}
   &xy[2].xx.a, &xy[2].xx, &global_float
 };
+
+const int A =  ((_Complex double)1.0 ? 21 : 1);
+_Static_assert(A == 21, ""); // pedantic-ref-warning {{GNU extension}} \
+                             // pedantic-expected-warning {{GNU extension}}
----------------
sethp wrote:

Some other test cases that might be interesting:

```C
const int foo = (__builtin_complex(0.0, 1.0));
const _Bool bar = (_Bool)(__builtin_complex(0.0, 1.0));
const _Bool baz = __builtin_complex(0.0, 1.0);
```

gcc (but not clang) seems to think `baz` ought not produce a constant value: https://godbolt.org/z/TEYWzzK7c 

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


More information about the cfe-commits mailing list