Skip to content

[clang][BoundsSafety] err_count_attr_not_on_ptr_or_flexible_array_member wording is inaccurate under -fbounds-safety (__counted_by is supported on arrays) #13416

Description

@delcypher

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:bounds-safetyIssue relating to the experimental -fbounds-safety feature in Clang

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions