Summary
The diagnostic err_count_attr_not_on_ptr_or_flexible_array_member reads:
'' only applies to pointers or C99 flexible array members
Under -fbounds-safety, __counted_by is also accepted on arrays, so "only
applies to pointers or C99 flexible array members" is only partially accurate in that
mode. (Note the __sized_by, __sized_by_or_null, and __counted_by_or_null
variants are not accepted on arrays.)
Where
clang/include/clang/Basic/DiagnosticSemaKinds.td carries a FIXME above
def err_count_attr_not_on_ptr_or_flexible_array_member:
// FIXME: Stating `or C99 flexible array members` is only partially true.
// In `-fbounds-safety` we also support it on arrays too.
This was introduced when -fbounds-safety migrated from err_attribute_pointers_only
to this upstream diagnostic in #13398.
Suggested fix
Reword the diagnostic (or add a -fbounds-safety-specific %select variant) so the
message accurately reflects that __counted_by is also supported on arrays under
-fbounds-safety.
Summary
The diagnostic
err_count_attr_not_on_ptr_or_flexible_array_memberreads:Under
-fbounds-safety,__counted_byis also accepted on arrays, so "onlyapplies to pointers or C99 flexible array members" is only partially accurate in that
mode. (Note the
__sized_by,__sized_by_or_null, and__counted_by_or_nullvariants are not accepted on arrays.)
Where
clang/include/clang/Basic/DiagnosticSemaKinds.tdcarries a FIXME abovedef err_count_attr_not_on_ptr_or_flexible_array_member:This was introduced when
-fbounds-safetymigrated fromerr_attribute_pointers_onlyto this upstream diagnostic in #13398.
Suggested fix
Reword the diagnostic (or add a
-fbounds-safety-specific%selectvariant) so themessage accurately reflects that
__counted_byis also supported on arrays under-fbounds-safety.