A patch is below.  This should apply to both 0.2.5-rc6 and to 0.2.5-rc7, 
which is so far only available on the Ubuntu PPA.

A possible semantic match is as follows:

@@
identifier f,x;
type T;
@@

f(...,T x[],...) {
<...
* sizeof(x)
...>
}

@@
identifier f,x;
type T;
expression e;
@@

f(...,T x[e],...) {
<...
* sizeof(x)
...>
}

julia

----

diff -u -p a/parsing_cocci/parser_cocci_menhir.mly 
b/parsing_cocci/parser_cocci_menhir.mly
--- a/parsing_cocci/parser_cocci_menhir.mly     2011-02-28 11:40:43.000000000 
+0100
+++ b/parsing_cocci/parser_cocci_menhir.mly     2011-02-28 21:34:56.000000000 
+0100
@@ -989,8 +989,8 @@ storage:
        | s=Tregister    { P.clt2mcode Ast.Register s }
        | s=Textern      { P.clt2mcode Ast.Extern s }
 
-decl: t=ctype i=disj_ident
-       { Ast0.wrap(Ast0.Param(t, Some i)) }
+decl: t=ctype i=disj_ident a=list(array_dec)
+       { let t = P.arrayify t a in Ast0.wrap(Ast0.Param(t, Some i)) }
     | t=ctype { (*verify in FunDecl*) Ast0.wrap(Ast0.Param(t, None)) }
     | t=ctype lp=TOPar s=TMul i=disj_ident rp=TCPar
        lp1=TOPar d=decl_list(name_opt_decl) rp1=TCPar
@@ -1238,14 +1238,7 @@ one_decl_var:
 
 d_ident:
     disj_ident list(array_dec)
-      { ($1,
-        function t ->
-          List.fold_right
-            (function (l,i,r) ->
-              function rest ->
-                Ast0.wrap
-                  (Ast0.Array(rest,P.clt2mcode "[" l,i,P.clt2mcode "]" r)))
-            $2 t) }
+      { ($1, function t -> P.arrayify t $2) }
 
 array_dec: l=TOCro i=option(eexpr) r=TCCro { (l,i,r) }
 
diff -u -p a/parsing_cocci/parse_aux.ml b/parsing_cocci/parse_aux.ml
--- a/parsing_cocci/parse_aux.ml        2011-02-28 11:40:43.000000000 +0100
+++ b/parsing_cocci/parse_aux.ml        2011-02-28 21:34:23.000000000 +0100
@@ -178,6 +178,13 @@ let ty_pointerify ty m =
     (function inner -> function cur -> Type_cocci.Pointer(inner))
     ty m
 
+let arrayify ty ar =
+  List.fold_right
+    (function (l,i,r) ->
+      function rest ->
+       Ast0.wrap (Ast0.Array(rest,clt2mcode "[" l,i,clt2mcode "]" r)))
+    ar ty
+
 (* Left is <=>, Right is =>.  Collect <=>s. *)
 (* The parser should have done this, with precedences.  But whatever... *)
 let iso_adjust first_fn fn first rest =
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to