Summary
When __counted_by / __counted_by_or_null is applied to a pointer whose pointee has
unknown size (incomplete / sizeless / function / flexible-array-member), the previous
downstream diagnostic (err_bounds_safety_counted_by_without_size) offered a FixIt
suggesting __sized_by / __sized_by_or_null. Migrating to the upstream
err_counted_by_attr_pointee_unknown_size diagnostic (#13398)
dropped that FixIt, since the upstream diagnostic doesn't emit it.
Where
clang/lib/Sema/SemaBoundsSafety.cpp (ValidateBoundsAttrTypeShape) carries a FIXME:
// FIXME: We should suggest `__sized_by(_or_null)` and in the error
// diagnostic case emit a FixIt.
The corresponding FixIt checks were also removed from tests, e.g.
clang/test/BoundsSafety/Sema/counted_by_type_unknown_size.c.
Suggested fix
Re-introduce the __sized_by / __sized_by_or_null FixIt for the error case, and
restore the fixit checks in the affected tests.
Summary
When
__counted_by/__counted_by_or_nullis applied to a pointer whose pointee hasunknown size (incomplete / sizeless / function / flexible-array-member), the previous
downstream diagnostic (
err_bounds_safety_counted_by_without_size) offered a FixItsuggesting
__sized_by/__sized_by_or_null. Migrating to the upstreamerr_counted_by_attr_pointee_unknown_sizediagnostic (#13398)dropped that FixIt, since the upstream diagnostic doesn't emit it.
Where
clang/lib/Sema/SemaBoundsSafety.cpp(ValidateBoundsAttrTypeShape) carries a FIXME:The corresponding FixIt checks were also removed from tests, e.g.
clang/test/BoundsSafety/Sema/counted_by_type_unknown_size.c.Suggested fix
Re-introduce the
__sized_by/__sized_by_or_nullFixIt for the error case, andrestore the fixit checks in the affected tests.