================
@@ -185,3 +185,12 @@ struct ptr_no_attr {
void test11(struct ptr_no_attr *p) {
_Static_assert(_Generic(__builtin_counted_by_ref(p->ptr), void * : 1,
default : 0) == 1, "should be void*");
}
+
+struct bitfield_counter {
+ int count : 13; // expected-note {{counter field 'count' declared here}}
+ int array[] __attribute__((counted_by(count)));
+};
+
+void test_bitfield_counter(struct bitfield_counter *p) {
+ __builtin_counted_by_ref(p->array); // expected-error
{{'__builtin_counted_by_ref' cannot be used on 'p->array' because its counter
field is a bit-field}}
----------------
delcypher wrote:
I'm not a big fan of the "counter field" terminology as it's not something we
normally use in `-fbounds-safety`.
How about wording it like this?
```
error: '__builtin_counted_by_ref' cannot be used on 'p->array' because its
'counted_by' attribute refers to bit field 'count'
```
note: 'count' declared here.
I think this is better because
* We aren't introducing new terminology ("counter field").
* We explain that this comes from the `counted_by` attribute which the previous
wording never mentioned.
https://github.com/llvm/llvm-project/pull/231591
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits