Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / attr-counted-by.c
blob654ddb7f1b42b1a4bbd6b43f42bf0cb5cc7d9f3b
1 // RUN: %clang_cc1 -fstrict-flex-arrays=3 -fsyntax-only -verify %s
3 #define __counted_by(f) __attribute__((counted_by(f)))
5 struct bar;
7 struct not_found {
8 int count;
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 {
20 int bork;
21 struct bar *fam[] __counted_by(global); // expected-error {{field 'global' in 'counted_by' not inside structure}}
24 struct self_referrential {
25 int bork;
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}}
39 struct not_a_fam {
40 int count;
41 struct bar *non_fam __counted_by(count); // expected-error {{'counted_by' only applies to flexible array members}}
44 struct annotated_with_anon_struct {
45 unsigned long flags;
46 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'?}}