Coccinelle release 1.0.0-rc3
[bpt/coccinelle.git] / parsing_cocci / check_meta.ml
index 8722f60..ba64535 100644 (file)
@@ -107,13 +107,25 @@ let rec ident context old_metas table minus i =
            warning
              (Printf.sprintf "line %d: should %s be a metavariable?" rl name)
       | _ -> ())
-  | Ast0.MetaId(name,_,_) -> check_table table minus name
+  | Ast0.MetaId(name,_,seedval,_) ->
+      check_table table minus name;
+      seed table minus seedval
   | Ast0.MetaFunc(name,_,_) -> check_table table minus name
   | Ast0.MetaLocalFunc(name,_,_) -> check_table table minus name
   | Ast0.DisjId(_,id_list,_,_) ->
       List.iter (ident context old_metas table minus) id_list
   | Ast0.OptIdent(_) | Ast0.UniqueIdent(_) ->
       failwith "unexpected code"
+
+and seed table minus = function
+    Ast.NoVal -> ()
+  | Ast.StringSeed _ -> ()
+  | Ast.ListSeed elems ->
+      List.iter
+       (function
+           Ast.SeedString _ -> ()
+         | Ast.SeedId name -> check_table table minus (promote name))
+       elems
        
 (* --------------------------------------------------------------------- *)
 (* Expression *)
@@ -334,7 +346,8 @@ and statement old_metas table minus s =
   match Ast0.unwrap s with
     Ast0.Decl(_,decl) -> declaration ID old_metas table minus decl
   | Ast0.Seq(lbrace,body,rbrace) -> dots (statement old_metas table minus) body
-  | Ast0.ExprStatement(exp,sem) -> expression ID old_metas table minus exp
+  | Ast0.ExprStatement(exp,sem) ->
+      get_opt (expression ID old_metas table minus) exp
   | Ast0.IfThen(iff,lp,exp,rp,branch,_) ->
       expression ID old_metas table minus exp;
       statement old_metas table minus branch
@@ -439,8 +452,9 @@ and case_line old_metas table minus c =
 
 let top_level old_metas table minus t =
   match Ast0.unwrap t with
-    Ast0.DECL(stmt) -> statement old_metas table minus stmt
-  | Ast0.CODE(stmt_dots) -> dots (statement old_metas table minus) stmt_dots
+    Ast0.NONDECL(stmt) -> statement old_metas table minus stmt
+  | Ast0.CODE(stmt_dots) | Ast0.TOPCODE(stmt_dots) ->
+      dots (statement old_metas table minus) stmt_dots
   | Ast0.ERRORWORDS(exps) ->
       List.iter (expression FN old_metas table minus) exps
   | _ -> () (* no metavariables possible *)