[PATCH] D148381: [Clang] Add counted_by attribute
Bill Wendling via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 6 13:14:39 PDT 2023
void added a comment.
In D148381#4639909 <https://reviews.llvm.org/D148381#4639909>, @kees wrote:
> I can generate warnings for anonymous structs were the `__counted_by` member is reported as "not found". For example:
>
> little.c:7:28: warning: counted_by field 'count' not found
> 7 | int array[] __counted_by(count);
> | ^~~~~
>
> For this:
>
> #define __counted_by(member) __attribute__((__counted_by__(member)))
>
> struct anon {
> unsigned long flags;
> struct {
> unsigned char count;
> int array[] __counted_by(count);
> };
> };
>
> extern void bar(int input);
>
> void foo(struct anon *p, int index)
> {
> bar(p->array[index]);
> }
I'll look into this.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148381/new/
https://reviews.llvm.org/D148381
More information about the cfe-commits
mailing list