Skip to content

Commit 4aaa315

Browse files
committed
Make gcc_attribute5 work: attributes in parentheses
1 parent 51bd8fb commit 4aaa315

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

regression/ansi-c/gcc_attributes5/main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ STATIC_ASSERT(__alignof(var7)==8);
2121

2222
void (__attribute__((aligned)) *****f1)(void);
2323
void (__attribute__((aligned)) f2)(void);
24+
25+
int __attribute__((cdecl,regparm(0))) *foo1(int x);
26+
int __attribute__((cdecl,regparm(0))) *(foo2)(int x);
27+
int (__attribute__((cdecl,regparm(0))) *foo3)(int x);
28+
int (* __attribute__((cdecl,regparm(0))) foo4)(int x);
29+
typedef int (__attribute__((cdecl,regparm(0))) foo5)(int x);
30+
typedef int (__attribute__((cdecl,regparm(0))) *foo6)(int x);
31+
typedef int* (__attribute__((cdecl,regparm(0))) *foo7)(int x);
2432

2533
#endif
2634

regression/ansi-c/gcc_attributes5/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33

44
^EXIT=0$

src/ansi-c/parser.y

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,6 +2881,32 @@ function_head:
28812881
declarator:
28822882
identifier_declarator
28832883
| typedef_declarator
2884+
| paren_attribute_declarator
2885+
;
2886+
2887+
paren_attribute_declarator:
2888+
'(' gcc_type_attribute_list identifier_declarator ')'
2889+
{
2890+
stack_type($1)=typet(ID_abstract);
2891+
$2=merge($2, $1); // dest=$2
2892+
make_subtype($3, $2); // dest=$3
2893+
$$=$3;
2894+
}
2895+
| '(' gcc_type_attribute_list identifier_declarator ')' postfixing_abstract_declarator
2896+
{
2897+
stack_type($1)=typet(ID_abstract);
2898+
$2=merge($2, $1); // dest=$2
2899+
make_subtype($3, $2); // dest=$3
2900+
/* note: this is (a pointer to) a function ($5) */
2901+
/* or an array ($5) with name ($3) */
2902+
$$=$3;
2903+
make_subtype($$, $5);
2904+
}
2905+
| '*' paren_attribute_declarator
2906+
{
2907+
$$=$2;
2908+
do_pointer($1, $2);
2909+
}
28842910
;
28852911

28862912
typedef_declarator:

src/ansi-c/parser_static.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ static void make_subtype(typet &dest, typet &src)
193193
src.id()==ID_pointer ||
194194
src.id()==ID_code ||
195195
src.id()==ID_merged_type ||
196+
src.id()==ID_abstract ||
196197
src.id()==ID_c_bit_field);
197198

198199
typet *p=&dest;

0 commit comments

Comments
 (0)