brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 5a739f9 Raw
39 lines · c
1// RUN: %clang_cc1 -fsyntax-only -fexperimental-bounds-safety -verify %s2// RUN: %clang_cc1 -fsyntax-only -fexperimental-bounds-safety -fexperimental-late-parse-attributes -verify %s3//4// This is a portion of the `attr-counted-by-vla.c` test but is checked5// under the semantics of `-fexperimental-bounds-safety` which has different6// behavior.7 8#define __counted_by(f)  __attribute__((counted_by(f)))9 10struct has_unannotated_VLA {11  int count;12  char buffer[];13};14 15struct has_annotated_VLA {16  int count;17  char buffer[] __counted_by(count);18};19 20struct buffer_of_structs_with_unnannotated_vla {21  int count;22  // 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}}23  struct has_unannotated_VLA Arr[] __counted_by(count);24};25 26 27struct buffer_of_structs_with_annotated_vla {28  int count;29  // 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}}30  struct has_annotated_VLA Arr[] __counted_by(count);31};32 33struct buffer_of_const_structs_with_annotated_vla {34  int count;35  // Make sure the `const` qualifier is printed when printing the element type.36  // 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}}37  const struct has_annotated_VLA Arr[] __counted_by(count);38};39