Files
clang-p2996/clang/test/Sema/attr-counted-by-bounds-safety-vlas.c
Dan Liew 876ee11eee [Bounds Safety][NFC] Add some missing coverage for -fexperimental-late-parse-attributes (#102236)
Previously we weren't properly checking that using
`-fexperimental-late-parse-attributes` worked on source code that didn't
need late parsing.

For example we weren't testing that the attribute appearing in the type
position generated the right AST with
`-fexperimental-late-parse-attributes` off.

This patch adds additional `RUN` lines to re-run the relevant test cases
with `-fexperimental-late-parse-attributes` enabled.

rdar://133325597
2024-08-08 09:57:47 -07:00

39 lines
1.5 KiB
C

// RUN: %clang_cc1 -fsyntax-only -fexperimental-bounds-safety -verify %s
// RUN: %clang_cc1 -fsyntax-only -fexperimental-bounds-safety -fexperimental-late-parse-attributes -verify %s
//
// This is a portion of the `attr-counted-by-vla.c` test but is checked
// under the semantics of `-fexperimental-bounds-safety` which has different
// behavior.
#define __counted_by(f) __attribute__((counted_by(f)))
struct has_unannotated_VLA {
int count;
char buffer[];
};
struct has_annotated_VLA {
int count;
char buffer[] __counted_by(count);
};
struct buffer_of_structs_with_unnannotated_vla {
int count;
// expected-error@+1{{'counted_by' cannot be applied to an array with element of unknown size because 'struct has_unannotated_VLA' is a struct type with a flexible array member}}
struct has_unannotated_VLA Arr[] __counted_by(count);
};
struct buffer_of_structs_with_annotated_vla {
int count;
// expected-error@+1{{'counted_by' cannot be applied to an array with element of unknown size because 'struct has_annotated_VLA' is a struct type with a flexible array member}}
struct has_annotated_VLA Arr[] __counted_by(count);
};
struct buffer_of_const_structs_with_annotated_vla {
int count;
// Make sure the `const` qualifier is printed when printing the element type.
// expected-error@+1{{'counted_by' cannot be applied to an array with element of unknown size because 'const struct has_annotated_VLA' is a struct type with a flexible array member}}
const struct has_annotated_VLA Arr[] __counted_by(count);
};