Skip to content
Snippets Groups Projects
Commit 6bd64624 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[parsing] Allow attributes in declarator lists

Previously, the parser only allowed attributes at beginning of a declaration
(like for `const`, `static`, ...). However, gcc accepts to have attributes
in the rest of the declaration (after the first comma, like for a pointer or
 array declarator).

Fixes #616
parent 9adc1f00
No related branches found
No related tags found
No related merge requests found
...@@ -1035,9 +1035,22 @@ declaration: /* ISO 6.7.*/ ...@@ -1035,9 +1035,22 @@ declaration: /* ISO 6.7.*/
init_declarator_list: /* ISO 6.7 */ init_declarator_list: /* ISO 6.7 */
init_declarator { [$1] } init_declarator { [$1] }
| init_declarator COMMA init_declarator_list { $1 :: $3 } | init_declarator COMMA init_declarator_attr_list { $1 :: $3 }
; ;
init_declarator_attr_list:
init_declarator_attr { [ $1 ] }
| init_declarator_attr COMMA init_declarator_attr_list { $1 :: $3 }
;
init_declarator_attr:
attribute_nocv_list init_declarator {
let ((name, decl, attrs, loc), init) = $2 in
((name, PARENTYPE ($1,decl,[]), attrs, loc), init)
}
;
init_declarator: /* ISO 6.7 */ init_declarator: /* ISO 6.7 */
declarator { ($1, NO_INIT) } declarator { ($1, NO_INIT) }
| declarator EQ init_expression | declarator EQ init_expression
......
...@@ -41,3 +41,7 @@ iptr h(volatile iptr ip2) { ...@@ -41,3 +41,7 @@ iptr h(volatile iptr ip2) {
} }
iptr volatile h(const iptr ip3); iptr volatile h(const iptr ip3);
void test(void) {
int a, __attribute__((unused)) b;
}
...@@ -42,4 +42,11 @@ iptr h(iptr volatile ip3) ...@@ -42,4 +42,11 @@ iptr h(iptr volatile ip3)
return __retres; return __retres;
} }
void test(void)
{
int a;
int b __attribute__((__unused__));
return;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment