[Linux-kernel-mentees] [PATCH v4 05/14] parsing_c: parser: Add expression statement attributes
Jaskaran Singh
jaskaransingh7654321 at gmail.com
Fri Jun 5 13:43:13 UTC 2020
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 <jaskaransingh7654321 at 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..e4352a61 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
More information about the Linux-kernel-mentees
mailing list