[clang] [Clang] Fix integer promotion of bit-fields in statement expressions (PR #225597)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 23 05:49:55 PDT 2026
================
@@ -7,3 +7,12 @@ void stmtexprs(int i) {
// expected-warning at +1 {{assumption is ignored because it contains (potential) side-effects}}
__builtin_assume( ({ if (i) ({ stmtexpr_fn(); }); 1; }) );
}
+
+struct S {
+ unsigned b : 3;
+};
+
+void test_bitfield_promotion(struct S s) {
+ _Static_assert(_Generic(+({ s.b; }), int: 1, unsigned: 2) == 1,
----------------
AaronBallman wrote:
Can you also add these test cases just to round out coverage:
```
_Static_assert(_Generic(+s.b, int: 1, unsigned: 2) == 1,
"this should be promoted");
_Static_assert(_Generic(({ s.b; }), int: 1, unsigned: 2) == 2,
"this one does not get promoted");
_Static_assert(_Generic(s.b, int: 1, unsigned: 2) == 2,
"nor does this one");
```
https://github.com/llvm/llvm-project/pull/225597
More information about the cfe-commits
mailing list