Propagate guards from compound literals

This fixes JIRA VER-456
This commit is contained in:
Michael Norrish 2015-09-30 12:08:52 +10:00
parent bb9e9d94b8
commit 2f9f49df1a
3 changed files with 55 additions and 1 deletions

View File

@ -788,7 +788,8 @@ fun mk_complit_upd thy cty rootty ((pth,value), ei) = let
end
fun rval s = mk_upds rootty pth (rval_of value s) $ (rval_of ei s)
in
mk_rval(rval, cty, false, eileft ei, eiright ei) |> add_ei_guards ei
mk_rval(rval, cty, false, eileft ei, eiright ei)
|> add_ei_guards ei |> add_ei_guards value
end

View File

@ -0,0 +1,19 @@
struct div_t {
unsigned q;
};
unsigned f0(unsigned n, unsigned d)
{
return n/d;
}
struct div_t f1(unsigned n, unsigned d)
{
struct div_t r = { n / d };
return r;
}
struct div_t f2(unsigned n, unsigned d)
{
return (struct div_t){n/d};
}

View File

@ -0,0 +1,34 @@
theory jiraver456
imports "../CTranslation"
begin
install_C_file "jiraver456.c"
context jiraver456
begin
thm f0_body_def
thm f1_body_def
thm f2_body_def
ML {*
fun count c th =
let
val t = Thm.concl_of th
fun incifGuard t i = if t = c then i + 1 else i
in
fold_aterms incifGuard t 0
end
val f = count @{const Div_0};
(f @{thm f1_body_def} = 1 andalso f @{thm f2_body_def} = 1 andalso f @{thm f0_body_def} = 1)
orelse
OS.Process.exit OS.Process.failure
*}
end
end