diff --git a/_oasis b/_oasis index 26e52ca7b4e9e4dce8d298d9b54bc6ede840a560..fc8ae77e2ef14f6a743de7e48306619110897cf6 100644 --- a/_oasis +++ b/_oasis @@ -1,6 +1,6 @@ OASISFormat: 0.4 Name: lustre-v6 -Version: 1.679 +Version: 1.680 Synopsis: The Lustre V6 Verimag compiler Description: This package contains: (1) lus2lic: the (current) name of the compiler (and interpreter via -exec). diff --git a/src/l2lCheckCKeyWord.ml b/src/l2lCheckCKeyWord.ml new file mode 100644 index 0000000000000000000000000000000000000000..0e4ac9405fe4ee1e8f07429c6be88eb332186dc5 --- /dev/null +++ b/src/l2lCheckCKeyWord.ml @@ -0,0 +1,77 @@ +(* Time-stamp: <modified the 10/01/2017 (at 18:44) by Erwan Jahier> *) + +open Lxm +open Lic +open AstPredef + +let dbg = (Lv6Verbose.get_flag "C") + +(********************************************************************************) + + + +module StringSet = + Set.Make(struct + type t = string + let compare = compare + end) + +let c_kw_list = [ + "asm"; "auto"; "break"; "case"; "cdecl"; "char"; "const"; "continue"; + "default"; "do"; "double"; "else"; "enum"; "extern"; "far"; "float"; "for"; + "goto"; "huge"; "if"; "inline"; "int"; "interrupt"; "long"; "near"; "pascal"; + "register"; "restrict"; "return"; "short"; "signed"; "sizeof"; "static"; + "struct"; "switch"; "typedef"; "union"; "unsigned"; "void"; "volatile"; + "while"; "_Bool"; "_Complex"; "_Imaginary"] + + + + +let c_kw = StringSet.of_list c_kw_list + +let (check_var_info : Lic.var_info -> unit) = + fun v -> + if StringSet.mem v.var_name_eff c_kw then + let msg = Printf.sprintf "'%s' is a reserved C word. You cannot use it as a Lustre ident *and* use the C code generator, sorry" v.var_name_eff + in + raise (Lv6errors.Global_error msg) + + +let (check_type :Lic.type_ -> unit) = + fun typ -> + (* (match typ.Named_type_exp with + |id_pack -> () + |id_id ->) *) + () +(* List.iter check_var_info typ.named_type_exp.id_id +*) +let (check_const : Lic.const -> unit) = + fun const -> + (* List.iter check_var_info const.CallByName.STRUCT_n.id_id + *) +() + (* (match const.CallByName.STRUCT_n with + |id_pack -> () + |id_id -> + List.iter Check_var_info id_id + ) + *) +(* | CallByName of (by_name_op srcflagged * (Lv6Id.t srcflagged * val_exp) list) *) + +let (check_node : Lic.node_exp -> unit) = + fun node -> + List.iter check_var_info node.inlist_eff; + List.iter check_var_info node.outlist_eff; + (match node.loclist_eff with + | None -> () + | Some l -> List.iter check_var_info l) + +(********************************************************************************) + +(* exported *) + +let (doit : LicPrg.t -> unit) = + fun inprg -> + LicPrg.iter_nodes (fun _ n -> check_node n) inprg; + LicPrg.iter_types (fun _ t -> check_type t) inprg; + LicPrg.iter_consts (fun _ c -> check_const c) inprg; diff --git a/src/l2lCheckCKeyWord.mli b/src/l2lCheckCKeyWord.mli new file mode 100644 index 0000000000000000000000000000000000000000..9ec736d3cdbdb4b891d7ac0a52ba3a06ba5910b9 --- /dev/null +++ b/src/l2lCheckCKeyWord.mli @@ -0,0 +1,5 @@ +(* Time-stamp: <modified the 10/01/2017 (at 18:15) by Erwan Jahier> *) + +(** Check that the input program ident does not use C keywords *) + +val doit : LicPrg.t -> unit diff --git a/src/l2lCheckKcgKeyWord.ml b/src/l2lCheckKcgKeyWord.ml index ec6499bcf9e7977c1c87fa46c351811055ebdca5..ce154cffac03f04db69d4e7ef1a67b977bed5407 100644 --- a/src/l2lCheckKcgKeyWord.ml +++ b/src/l2lCheckKcgKeyWord.ml @@ -32,7 +32,8 @@ let kcg_kw = StringSet.of_list kcg_kw_list let (check_var_info : Lic.var_info -> unit) = fun v -> if StringSet.mem v.var_name_eff kcg_kw then - let msg = "kcg name clash" in + let msg = Printf.sprintf "'%s' is a reserved KCG word. You cannot use it as a Lustre ident *and* use the KCG code generator, sorry" v.var_name_eff + in raise (Lv6errors.Global_error msg) diff --git a/src/lv6Compile.ml b/src/lv6Compile.ml index a18dd58c8c51c70c3e9aae8d32613249c0f067e3..84d74aab3c01bc964ef6ed2a0b70da97ec9fc71a 100644 --- a/src/lv6Compile.ml +++ b/src/lv6Compile.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 31/08/2016 (at 17:26) by Erwan Jahier> *) +(* Time-stamp: <modified the 10/01/2017 (at 18:39) by Erwan Jahier> *) open Lxm open Lv6errors @@ -42,6 +42,8 @@ let (doit : Lv6MainArgs.t -> AstV6.pack_or_model list -> Lv6Id.idref option -> L let zelic = LicTab.to_lic_prg lic_tab in if opt.Lv6MainArgs.print_interface then zelic else ( profile_info "Check safety and memory declarations...\n"; + if opt.Lv6MainArgs.gen_c then + L2lCheckCKeyWord.doit zelic; if Lv6MainArgs.global_opt.Lv6MainArgs.kcg then L2lCheckKcgKeyWord.doit zelic else diff --git a/src/lv6version.ml b/src/lv6version.ml index a630731967f3be82feda259f8f45850efeee344d..3e2c05aad557a78d27883904e444ad2bdaf3372a 100644 --- a/src/lv6version.ml +++ b/src/lv6version.ml @@ -1,7 +1,7 @@ (** Automatically generated from Makefile *) let tool = "lus2lic" let branch = "master" -let commit = "679" -let sha_1 = "946ca4cf5781377ea43c0247b80d09606517ea56" +let commit = "680" +let sha_1 = "85804240652117595d47f55e0b8ac6765fa9120c" let str = (branch ^ "." ^ commit ^ " (" ^ sha_1 ^ ")") let maintainer = "jahier@imag.fr" diff --git a/test/lus2lic.sum b/test/lus2lic.sum index 90829ba9fea07dcb15edd3189942769f7bf4b9b9..46cb1e901bfcbdecea9fd54378a62f480ae7cb6a 100644 --- a/test/lus2lic.sum +++ b/test/lus2lic.sum @@ -1,5 +1,5 @@ ==> lus2lic0.sum <== -Test Run By jahier on Tue Jan 10 18:31:09 +Test Run By jahier on Tue Jan 10 18:45:26 Native configuration is x86_64-unknown-linux-gnu === lus2lic0 tests === @@ -64,7 +64,7 @@ XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/lecte XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/s.lus ==> lus2lic1.sum <== -Test Run By jahier on Tue Jan 10 18:31:10 +Test Run By jahier on Tue Jan 10 18:45:27 Native configuration is x86_64-unknown-linux-gnu === lus2lic1 tests === @@ -399,7 +399,7 @@ PASS: sh multipar.sh PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c multipar.lus {} ==> lus2lic2.sum <== -Test Run By jahier on Tue Jan 10 18:31:29 +Test Run By jahier on Tue Jan 10 18:45:46 Native configuration is x86_64-unknown-linux-gnu === lus2lic2 tests === @@ -745,7 +745,7 @@ PASS: sh zzz2.sh PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c zzz2.lus {} ==> lus2lic3.sum <== -Test Run By jahier on Tue Jan 10 18:32:08 +Test Run By jahier on Tue Jan 10 18:46:26 Native configuration is x86_64-unknown-linux-gnu === lus2lic3 tests === @@ -1251,7 +1251,7 @@ PASS: ./myec2c {-o multipar.c multipar.ec} PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node multipar.lus {} ==> lus2lic4.sum <== -Test Run By jahier on Tue Jan 10 18:32:19 +Test Run By jahier on Tue Jan 10 18:46:37 Native configuration is x86_64-unknown-linux-gnu === lus2lic4 tests === @@ -1777,12 +1777,12 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node zzz2.lus {} # Total number of failures: 24 lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 1 seconds lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 19 seconds -lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 39 seconds +lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 40 seconds lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 11 seconds lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 30 seconds * Ref time: -0.05user 0.04system 1:39.96elapsed 0%CPU (0avgtext+0avgdata 5672maxresident)k -96inputs+0outputs (0major+6149minor)pagefaults 0swaps +0.06user 0.05system 1:41.09elapsed 0%CPU (0avgtext+0avgdata 5672maxresident)k +96inputs+0outputs (0major+6148minor)pagefaults 0swaps * Quick time (-j 4): -0.06user 0.03system 0:50.78elapsed 0%CPU (0avgtext+0avgdata 5672maxresident)k -64inputs+0outputs (0major+6154minor)pagefaults 0swaps +0.06user 0.02system 0:43.77elapsed 0%CPU (0avgtext+0avgdata 5712maxresident)k +0inputs+0outputs (0major+6177minor)pagefaults 0swaps