As per GCC's C grammar, the expression statement rule has the following production:
expression-statement: gnu-attributes ; Add this production to the expr_statement rule of Coccinelle's C parser. If attributes are recognized, this parses the following code successfully: label: attribute; Signed-off-by: Jaskaran Singh <jaskaransingh7654...@gmail.com> --- parsing_c/parser_c.mly | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parsing_c/parser_c.mly b/parsing_c/parser_c.mly index d259f12a..a858db56 100644 --- a/parsing_c/parser_c.mly +++ b/parsing_c/parser_c.mly @@ -1082,8 +1082,9 @@ stat_or_decl: expr_statement: - | TPtVirg { None, [$1] } - | expr TPtVirg { Some $1, [$2] } + | TPtVirg { None, [$1] } + | end_attributes TPtVirg { None, [$2] } + | expr TPtVirg { Some $1, [$2] } selection: | Tif TOPar expr TCPar cpp_ifdef_statement %prec SHIFTHERE -- 2.21.1 _______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci