1 // RUN: %clang_cc1 -fstrict-flex-arrays=3 -fsyntax-only -verify %s
3 #define __counted_by(f) __attribute__((counted_by(f)))
9 struct bar
*fam
[] __counted_by(bork
); // expected-error {{use of undeclared identifier 'bork'}}
12 struct not_found_suggest
{
13 int bork
; // expected-note {{'bork' declared here}}
14 struct bar
*fam
[] __counted_by(blork
); // expected-error {{use of undeclared identifier 'blork'; did you mean 'bork'?}}
17 int global
; // expected-note {{'global' declared here}}
19 struct found_outside_of_struct
{
21 struct bar
*fam
[] __counted_by(global
); // expected-error {{field 'global' in 'counted_by' not inside structure}}
24 struct self_referrential
{
26 struct bar
*self
[] __counted_by(self
); // expected-error {{'counted_by' cannot refer to the flexible array 'self'}}
29 struct non_int_count
{
30 double dbl_count
; // expected-note {{field 'dbl_count' declared here}}
31 struct bar
*fam
[] __counted_by(dbl_count
); // expected-error {{field 'dbl_count' in 'counted_by' must be a non-boolean integer type}}
34 struct array_of_ints_count
{
35 int integers
[2]; // expected-note {{field 'integers' declared here}}
36 struct bar
*fam
[] __counted_by(integers
); // expected-error {{field 'integers' in 'counted_by' must be a non-boolean integer type}}
41 struct bar
*non_fam
__counted_by(count
); // expected-error {{'counted_by' only applies to flexible array members}}
44 struct annotated_with_anon_struct
{
47 unsigned char count
; // expected-note {{'count' declared here}}
48 int array
[] __counted_by(crount
); // expected-error {{use of undeclared identifier 'crount'; did you mean 'count'?}}