Skip to content

Commit 9ed2f72

Browse files
tautschnigDaniel Kroening
authored and
Daniel Kroening
committed
C front-end: support storage class and attributes for aggregate objects
Previously we would only support either storage class/type qualifiers _or_ GCC attributes.
1 parent 4bb7393 commit 9ed2f72

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
int main()
2+
{
3+
struct S
4+
{
5+
int x;
6+
};
7+
8+
struct S static __attribute__((__section__(".somewhere")))
9+
elements1[] = {{0}};
10+
11+
struct
12+
{
13+
int a;
14+
int b;
15+
} static __attribute__((__section__(".somewhere"))) elements2[] = {{0, 0}};
16+
17+
return 0;
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$

src/ansi-c/parser.y

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,32 +1172,30 @@ basic_type_specifier:
11721172
}
11731173
;
11741174

1175-
/* no gcc type attributes after the following! */
11761175
sue_declaration_specifier:
11771176
declaration_qualifier_list elaborated_type_name
11781177
{
11791178
$$=merge($1, $2);
11801179
}
1181-
| sue_type_specifier storage_class
1180+
| sue_type_specifier storage_class gcc_type_attribute_opt
11821181
{
1183-
$$=merge($1, $2);
1182+
$$=merge($1, merge($2, $3));
11841183
}
1185-
| sue_declaration_specifier declaration_qualifier
1184+
| sue_declaration_specifier declaration_qualifier gcc_type_attribute_opt
11861185
{
1187-
$$=merge($1, $2);
1186+
$$=merge($1, merge($2, $3));
11881187
}
11891188
;
11901189

1191-
/* no gcc type attributes after the following! */
11921190
sue_type_specifier:
11931191
elaborated_type_name
11941192
| type_qualifier_list elaborated_type_name
11951193
{
11961194
$$=merge($1, $2);
11971195
}
1198-
| sue_type_specifier type_qualifier
1196+
| sue_type_specifier type_qualifier gcc_type_attribute_opt
11991197
{
1200-
$$=merge($1, $2);
1198+
$$=merge($1, merge($2, $3));
12011199
}
12021200
;
12031201

0 commit comments

Comments
 (0)