blob: e8b54c2de1c05d6e88b4e02d8b5c8fff7486bf75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/* Testing the correct usage of attribute counted_by. */
/* { dg-do compile } */
/* { dg-options "-O2" } */
#include <wchar.h>
int size;
int x __attribute ((counted_by (size))); /* { dg-error "attribute is not allowed for a non-field declaration" } */
struct trailing {
int count;
int field __attribute ((counted_by (count))); /* { dg-error "attribute is not allowed for a non-array field" } */
};
struct trailing_1 {
int count;
int array_1[0] __attribute ((counted_by (count))); /* { dg-error "attribute is not allowed for a non-flexible array member field" } */
};
int count;
struct trailing_array_2 {
int count;
int array_2[] __attribute ((counted_by ("count"))); /* { dg-error "argument is not an identifier" } */
};
struct trailing_array_3 {
int other;
int array_3[] __attribute ((counted_by (L"count"))); /* { dg-error "argument is not an identifier" } */
};
struct trailing_array_4 {
int other;
int array_4[] __attribute ((counted_by (count))); /* { dg-error "attribute is not a field declaration in the same structure as" } */
};
int count;
struct trailing_array_5 {
float count;
int array_5[] __attribute ((counted_by (count))); /* { dg-error "attribute is not a field declaration with an integer type" } */
};
struct trailing_array_6 {
int count;
int array_6[] __attribute ((counted_by (count))) __attribute ((counted_by (count)));
};
struct trailing_array_7 {
int count1;
int count2;
int array_7[] __attribute ((counted_by (count1))) __attribute ((counted_by (count2))); /* { dg-error "conflicts with previous declaration" } */
};
struct trailing_array_8 {
_Bool count;
int array_8[] __attribute ((counted_by (count)));
};
enum week {Mon, Tue, Wed};
struct trailing_array_9 {
enum week days;
int array_9[] __attribute ((counted_by (days)));
};
|