From a6b6bf31121d975c915c01f501618d97df7879fb Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Sat, 9 May 2015 09:00:51 +0200 Subject: Extended inline asm: revised treatment of clobbered registers. - Treat clobbered registers as being destroyed by EF_inline_asm builtins (which is the truth, semantically). - To enable the above, represent clobbers as Coq strings rather than idents and move register_by_name from Machregsaux.ml to Machregs.v. - Side benefit: more efficient implementation of Machregsaux.name_of_register. -# Please enter the commit message for your changes. Lines starting --- cparser/ExtendedAsm.ml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cparser') diff --git a/cparser/ExtendedAsm.ml b/cparser/ExtendedAsm.ml index 94d23102..fbf8d569 100644 --- a/cparser/ExtendedAsm.ml +++ b/cparser/ExtendedAsm.ml @@ -161,9 +161,10 @@ let transf_outputs loc env = function let check_clobbers loc clob = List.iter (fun c -> - if Machregsaux.register_by_name c <> None - || List.mem c Machregsaux.scratch_register_names - || c = "memory" || c = "cc" + let c' = String.uppercase c in + if Machregsaux.register_by_name c' <> None + || List.mem c' Machregsaux.scratch_register_names + || c' = "MEMORY" || c' = "CC" then () else error "%aError: unrecognized asm register clobber '%s'" formatloc loc c) -- cgit From ad613e10f78bfe11e2df2ec055bcd02406456476 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Wed, 13 May 2015 18:56:53 +0200 Subject: Changed the enter_or_refine_ident function to produce an error if a non-static declaration is followed by a static declaration/definition. --- cparser/Elab.ml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'cparser') diff --git a/cparser/Elab.ml b/cparser/Elab.ml index 10af10a1..4e8ef214 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -1801,12 +1801,20 @@ let enter_or_refine_ident local loc env s sto ty = | None -> warning loc "redefinition of '%s' with incompatible type" s; ty in let new_sto = - if old_sto = Storage_extern then sto else - if sto = Storage_extern then old_sto else - if old_sto = sto then sto else begin - warning loc "redefinition of '%s' with incompatible storage class" s; - sto - end in + (* The only case not allowed is removing static *) + match old_sto,sto with + | Storage_static,Storage_static + | Storage_extern,Storage_extern + | Storage_register,Storage_register + | Storage_default,Storage_default -> sto + | _,Storage_static -> + error loc "static redefinition of '%s' after non-static definition" s; sto + | Storage_static,_ -> Storage_static (* Static stays static *) + | Storage_extern,_ -> sto + | _,Storage_extern -> old_sto + | _,Storage_register + | Storage_register,_ -> Storage_register + in (id, new_sto, Env.add_ident env id new_sto new_ty) | Some(id, II_enum v) when Env.in_current_scope env id -> error loc "illegal redefinition of enumerator '%s'" s; -- cgit From 5d017f110f6c23c29a182465ab7832a944c0ba26 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 14 May 2015 12:53:02 +0200 Subject: Make a register as storage specify to a fatal error. --- cparser/Elab.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cparser') diff --git a/cparser/Elab.ml b/cparser/Elab.ml index 4e8ef214..fe74a786 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -1862,7 +1862,7 @@ let enter_decdefs local loc env sto dl = let elab_fundef env spec name body loc = let (s, sto, inline, ty, env1) = elab_name env spec name in if sto = Storage_register then - error loc "a function definition cannot have 'register' storage class"; + fatal_error loc "a function definition cannot have 'register' storage class"; (* Fix up the type. We can have params = None but only for an old-style parameterless function "int f() {...}" *) let ty = -- cgit