Skip to content

Commit b41bad6

Browse files
authored
Change member_shift (fix rems-project/cerberus#728)
This commit propagates a breaking change to syntax of CN, specifically member_shift Previously: ```c struct s; typedef struct s td; /*@ member_shift<s>(..); @*/ // <-- okay /*@ member_shift<struct s>(..); @*/ // <-- not allowed /*@ member_shift<td>(..); @*/ // <-- not supported ``` Now: ```c struct s; typedef struct s td; /*@ member_shift<s>(..); @*/ // <-- not allowed /*@ member_shift<struct s>(..); @*/ // <-- okay /*@ member_shift<td>(..); @*/ // <-- okay ``` The change is breaking, and it's seems impractical to do it in a backwards compatible way because of a parser conflict, but is easy to update with a simple sed command `sed -i 's/member_shift</&struct /g'`.
1 parent 76ce700 commit b41bad6

9 files changed

+13
-12
lines changed

cn.opam

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ depends: [
2323
"zarith" {>= "1.13"}
2424
]
2525
pin-depends: [
26-
["cerberus-lib.dev" "git+https://github.com/rems-project/cerberus.git#3c75d1b"]
26+
["cerberus-lib.dev" "git+https://github.com/rems-project/cerberus.git#2d84326"]
2727
]
2828
build: [
2929
["dune" "subst"] {pinned}

lib/compile.ml

+3-2
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ module EffectfulTranslation = struct
882882
return (IT (it_, Loc (Some member_ty), loc))
883883
in
884884
(match (opt_tag, IT.get_bt e) with
885-
| Some tag, Loc (Some (Struct tag')) ->
885+
| Some (Ctype (_, Struct tag)), Loc (Some (Struct tag')) ->
886886
if Sym.equal tag tag' then
887887
with_tag tag
888888
else (
@@ -895,7 +895,8 @@ module EffectfulTranslation = struct
895895
(Illtyped_it
896896
{ it = Terms.pp e; has = SBT.pp (Struct tag'); expected; reason })
897897
})
898-
| Some tag, Loc None | None, Loc (Some (Struct tag)) -> with_tag tag
898+
| Some (Ctype (_, Struct tag)), Loc None | None, Loc (Some (Struct tag)) ->
899+
with_tag tag
899900
| None, Loc None -> cannot_tell_pointee_ctype loc e
900901
| _, has ->
901902
let expected = "struct pointer" in

lib/pp_mucore_coq.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ let rec pp_cn_expr ppfa ppfty = function
15481548
"CNExpr_membershift"
15491549
[ pp_triple
15501550
(pp_cn_expr ppfa ppfty)
1551-
(pp_option ppfa)
1551+
(pp_option ppfty)
15521552
pp_identifier
15531553
(e, oa, id)
15541554
]

tests/cn/has_alloc_id_shift.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct s {
2828
void member_shift(struct s *p)
2929
/*@
3030
requires
31-
has_alloc_id(member_shift<s>(p, x));
31+
has_alloc_id(member_shift<struct s>(p, x));
3232
ensures
3333
has_alloc_id(p);
3434
@*/
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
return code: 2
22
tests/cn/list_literal_type.error.c:3:15: error: unexpected token after 'list' and before '<'
3-
Please add error message for state 1889 to parsers/c/c_parser_error.messages
3+
Please add error message for state 1842 to parsers/c/c_parser_error.messages
44
function (list<integer>) nonempty_list() {
55
^

tests/cn/tree16/as_mutual_dt/tree16.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ predicate {datatype tree t, i32 v, map <i32, datatype tree> children}
3838
else {
3939
take P = RW<struct node>(p);
4040
let V = P.v;
41-
let nodes_ptr = member_shift<node>(p,nodes);
41+
let nodes_ptr = member_shift<struct node>(p,nodes);
4242
take Ns = each (i32 i; (0i32 <= i) && (i < NUM_NODES))
4343
{Indirect_Tree(array_shift<tree>(nodes_ptr, i))};
4444
let ts = array_to_tree_list (Ns, NUM_NODES);

tests/cn/tree16/as_mutual_dt/tree16.c.verify

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ tests/cn/tree16/as_mutual_dt/tree16.c:111:19: warning: 'each' prefers a 'u64', b
1111
tests/cn/tree16/as_mutual_dt/tree16.c:121:18: warning: 'each' prefers a 'u64', but 'j' has type 'i32'.
1212
take Xs2 = each (i32 j; (0i32 <= j) && (j < path_len))
1313
^
14-
other location (File "lib/compile.ml", line 1630, characters 38-45) warning: 'focus' prefers a 'u64', but 'read_&i1' has type 'i32'.
14+
other location (File "lib/compile.ml", line 1631, characters 38-45) warning: 'focus' prefers a 'u64', but 'read_&i1' has type 'i32'.
1515

16-
other location (File "lib/compile.ml", line 1630, characters 38-45) warning: 'focus' prefers a 'u64', but 'read_&idx0' has type 'i32'.
16+
other location (File "lib/compile.ml", line 1631, characters 38-45) warning: 'focus' prefers a 'u64', but 'read_&idx0' has type 'i32'.
1717

1818
[1/1]: lookup_rec -- pass

tests/cn/tree16/as_partial_map/tree16.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ predicate {map<datatype tree_arc, datatype tree_node_option> t,
5151
else {
5252
take P = RW<struct node>(p);
5353
let V = P.v;
54-
let nodes_ptr = member_shift<node>(p,nodes);
54+
let nodes_ptr = member_shift<struct node>(p,nodes);
5555
take Ns = each (i32 i; (0i32 <= i) && (i < (num_nodes ())))
5656
{Indirect_Tree(array_shift<tree>(nodes_ptr, i))};
5757
let t = construct (V, Ns);

tests/cn/tree16/as_partial_map/tree16.c.verify

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ tests/cn/tree16/as_partial_map/tree16.c:137:19: warning: 'each' prefers a 'u64',
1717
tests/cn/tree16/as_partial_map/tree16.c:146:18: warning: 'each' prefers a 'u64', but 'j' has type 'i32'.
1818
take Xs2 = each (i32 j; (0i32 <= j) && (j < path_len))
1919
^
20-
other location (File "lib/compile.ml", line 1630, characters 38-45) warning: 'focus' prefers a 'u64', but 'read_&i2' has type 'i32'.
20+
other location (File "lib/compile.ml", line 1631, characters 38-45) warning: 'focus' prefers a 'u64', but 'read_&i2' has type 'i32'.
2121

22-
other location (File "lib/compile.ml", line 1630, characters 38-45) warning: 'focus' prefers a 'u64', but 'read_&idx0' has type 'i32'.
22+
other location (File "lib/compile.ml", line 1631, characters 38-45) warning: 'focus' prefers a 'u64', but 'read_&idx0' has type 'i32'.
2323

2424
[1/2]: cn_get_num_nodes -- pass
2525
[2/2]: lookup_rec -- pass

0 commit comments

Comments
 (0)