blob: 058d58fb2931f8dec1f35b11cdd5070ea1ac5524 (
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/* Testing the correct usage of attribute counted_by in c23, multiple
* definitions of the same tag in same or different scopes.
* { dg-do compile }
* { dg-options "-std=c23" }
*/
/* Allowed redefinitions of the same struct in the same scope, with the
same counted_by attribute. */
struct f {
int b;
int c;
int a[] __attribute__ ((counted_by (b))); };
struct f {
int b;
int c;
int a[] __attribute__ ((counted_by (b))); };
struct f {
int b;
int c;
int a[]; }; /* { dg-error "redefinition of struct or union" } */
/* Error when the counted_by attribute is defined differently. */
struct f {
int b;
int c;
int a[] __attribute__ ((counted_by (c))); }; /* { dg-error "redefinition of struct or union" } */
struct h {
int b;
int c;
int a[] __attribute__ ((counted_by (b))); } p;
void test (void)
{
struct h {
int b;
int c;
int a[] __attribute__ ((counted_by (b))); } x;
p = x;
}
void test1 (void)
{
struct h {
int b;
int c;
int a[] __attribute__ ((counted_by (c))); } y;
p = y; /* { dg-error "incompatible types when assigning to type" } */
}
struct nested_f {
struct {
union {
int b;
float f;
};
int n;
};
char c[] __attribute__ ((counted_by (b)));
};
struct nested_f {
struct {
union {
int b;
float f;
};
int n;
};
char c[] __attribute__ ((counted_by (b)));
};
struct nested_f {
struct {
union {
int b;
float f;
};
int n;
};
char c[] __attribute__ ((counted_by (n)));
}; /* { dg-error "redefinition of struct or union" } */
struct nested_h {
struct {
union {
int b;
float f;
};
int n;
};
char c[] __attribute__ ((counted_by (b)));
} nested_p;
void test_2 (void)
{
struct nested_h {
struct {
union {
int b;
float f;
};
int n;
};
char c[] __attribute__ ((counted_by (b)));
} nested_x;
nested_p = nested_x;
}
void test_3 (void)
{
struct nested_h {
struct {
union {
int b;
float f;
};
int n;
};
char c[] __attribute__ ((counted_by (n)));
} nested_y;
nested_p = nested_y; /* { dg-error "incompatible types when assigning to type" } */
}
|