[Linux-kernel-mentees] [PATCH 4/4] parsing_c: parser: Use end_attributes_opt in cpp_other

Jaskaran Singh jaskaransingh7654321 at gmail.com
Mon Jun 8 12:20:37 UTC 2020


The cpp_other rule has redundant code due to an additional production
for end attributes. Use end_attributes_opt to resolve this.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321 at gmail.com>
---
 parsing_c/parser_c.mly | 34 +---------------------------------
 1 file changed, 1 insertion(+), 33 deletions(-)

diff --git a/parsing_c/parser_c.mly b/parsing_c/parser_c.mly
index 61bb1ca0..10cd4435 100644
--- a/parsing_c/parser_c.mly
+++ b/parsing_c/parser_c.mly
@@ -2202,39 +2202,7 @@ cpp_other:
     * the rule are slightly different, they can't be statement and so expr
     * at the top, only decl or function definition.
     *)*/
- | identifier TOPar argument_list TCPar TPtVirg
-     {
-       if args_are_params $3
-       then
-	 (* if all args are params, assume it is a prototype of a function
-	    with no return type *)
-	 let parameters = args_to_params $3 None in
-	 let paramlist = (parameters, (false, [])) in (* no varargs *)
-	 let id = RegularName (mk_string_wrap $1) in
-	 let ret =
-	   warning "type defaults to 'int'"
-	     (mk_ty defaultInt [fakeInfo fake_pi]) in
-	 let ty =
-	   fixOldCDecl (mk_ty (FunctionType (ret, paramlist)) [$2;$4]) in
-	 let attrs = Ast_c.noattr in
-	 let sto = (NoSto, false), [] in
-	 let iistart = Ast_c.fakeInfo () in
-	 Declaration(
-	 DeclList ([{v_namei = Some (id,NoInit); v_type = ty;
-                      v_storage = unwrap sto; v_local = NotLocalDecl;
-                      v_attr = attrs; v_endattr = Ast_c.noattr;
-		      v_type_bis = ref None;
-                    },[]],
-                   ($5::iistart::snd sto)))
-       else
-	 Declaration
-	   (MacroDecl
-             ((NoSto, fst $1, $3, Ast_c.noattr, true),
-               [snd $1;$2;$4;$5;fakeInfo()]))
-           (* old: MacroTop (fst $1, $3,    [snd $1;$2;$4;$5])  *)
-     }
-
- | identifier TOPar argument_list TCPar end_attributes TPtVirg
+ | identifier TOPar argument_list TCPar end_attributes_opt TPtVirg
      {
        if args_are_params $3
        then
-- 
2.21.1



More information about the Linux-kernel-mentees mailing list