Skip to content

Commit 3eac4a4

Browse files
clean up examples for unused variables
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent a44cf7a commit 3eac4a4

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

examples/c/test_capi.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ void display_model(Z3_context c, FILE * out, Z3_model m)
646646
a = Z3_mk_app(c, cnst, 0, 0);
647647
v = a;
648648
ok = Z3_model_eval(c, m, a, 1, &v);
649+
(void)ok;
649650
display_ast(c, out, v);
650651
fprintf(out, "\n");
651652
}
@@ -1377,12 +1378,11 @@ void tuple_example1()
13771378
{
13781379
/* demonstrate how to use the mk_tuple_update function */
13791380
/* prove that p2 = update(p1, 0, 10) implies get_x(p2) = 10 */
1380-
Z3_ast p1, p2, one, ten, updt, x, y;
1381+
Z3_ast p1, p2, ten, updt, x, y;
13811382
Z3_ast antecedent, consequent, thm;
13821383

13831384
p1 = mk_var(ctx, "p1", pair_sort);
13841385
p2 = mk_var(ctx, "p2", pair_sort);
1385-
one = Z3_mk_numeral(ctx, "1", real_sort);
13861386
ten = Z3_mk_numeral(ctx, "10", real_sort);
13871387
updt = mk_tuple_update(ctx, p1, 0, ten);
13881388
antecedent = Z3_mk_eq(ctx, p2, updt);
@@ -1558,7 +1558,6 @@ void error_code_example1()
15581558
Z3_ast x;
15591559
Z3_model m;
15601560
Z3_ast v;
1561-
Z3_func_decl x_decl;
15621561
const char * str;
15631562

15641563
printf("\nerror_code_example1\n");
@@ -1571,7 +1570,6 @@ void error_code_example1()
15711570
s = mk_solver(ctx);
15721571

15731572
x = mk_bool_var(ctx, "x");
1574-
x_decl = Z3_get_app_decl(ctx, Z3_to_app(ctx, x));
15751573
Z3_solver_assert(ctx, s, x);
15761574

15771575
if (Z3_solver_check(ctx, s) != Z3_L_TRUE) {
@@ -1588,6 +1586,7 @@ void error_code_example1()
15881586
}
15891587
/* The following call will fail since the value of x is a boolean */
15901588
str = Z3_get_numeral_string(ctx, v);
1589+
(void)str;
15911590
if (Z3_get_error_code(ctx) != Z3_OK) {
15921591
printf("last call failed.\n");
15931592
}
@@ -1619,6 +1618,7 @@ void error_code_example2() {
16191618
printf("before Z3_mk_iff\n");
16201619
/* the next call will produce an error */
16211620
app = Z3_mk_iff(ctx, x, y);
1621+
(void)app;
16221622
e = Z3_get_error_code(ctx);
16231623
if (e != Z3_OK) goto err;
16241624
unreachable();
@@ -2080,6 +2080,10 @@ void forest_example() {
20802080
Z3_query_constructor(ctx, cons2_con, 2, &cons2_decl, &is_cons2_decl, cons_accessors);
20812081
car2_decl = cons_accessors[0];
20822082
cdr2_decl = cons_accessors[1];
2083+
(void)cdr2_decl;
2084+
(void)car2_decl;
2085+
(void)car1_decl;
2086+
(void)cdr1_decl;
20832087

20842088
Z3_del_constructor_list(ctx, clist1);
20852089
Z3_del_constructor_list(ctx, clist2);
@@ -2097,7 +2101,10 @@ void forest_example() {
20972101
t4 = mk_binary_app(ctx, cons2_decl, nil1, f1);
20982102
f2 = mk_binary_app(ctx, cons1_decl, t1, nil1);
20992103
f3 = mk_binary_app(ctx, cons1_decl, t1, f1);
2100-
2104+
(void)f3;
2105+
(void)f2;
2106+
(void)t4;
2107+
(void)t2;
21012108

21022109
/* nil != cons(nil,nil) */
21032110
prove(ctx, s, Z3_mk_not(ctx, Z3_mk_eq(ctx, nil1, f1)), true);
@@ -2165,6 +2172,7 @@ void binary_tree_example() {
21652172

21662173
/* create the new recursive datatype */
21672174
cell = Z3_mk_datatype(ctx, Z3_mk_string_symbol(ctx, "BinTree"), 2, constructors);
2175+
(void)cell;
21682176

21692177
/* retrieve the new declarations: constructors (nil_decl, node_decl), testers (is_nil_decl, is_cons_del), and
21702178
accessors (value_decl, left_decl, right_decl */
@@ -2447,6 +2455,7 @@ void incremental_example1() {
24472455
c3 = assert_retractable_cnstr(ext_ctx, Z3_mk_gt(ctx, x, two));
24482456
/* assert y < 1 */
24492457
c4 = assert_retractable_cnstr(ext_ctx, Z3_mk_lt(ctx, y, one));
2458+
(void)c1;
24502459

24512460
result = ext_check(ext_ctx);
24522461
if (result != Z3_L_FALSE)

examples/maxsat/maxsat.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ int naive_maxsat(Z3_context ctx, Z3_solver s, unsigned num_hard_cnstrs, Z3_ast *
407407
{
408408
Z3_ast * aux_vars;
409409
Z3_lbool is_sat;
410-
unsigned r, k;
410+
unsigned k;
411411
assert_hard_constraints(ctx, s, num_hard_cnstrs, hard_cnstrs);
412412
printf("checking whether hard constraints are satisfiable...\n");
413413
is_sat = Z3_solver_check(ctx, s);
@@ -419,7 +419,6 @@ int naive_maxsat(Z3_context ctx, Z3_solver s, unsigned num_hard_cnstrs, Z3_ast *
419419
return 0; // nothing to be done...
420420
aux_vars = assert_soft_constraints(ctx, s, num_soft_cnstrs, soft_cnstrs);
421421
// Perform linear search.
422-
r = 0;
423422
k = num_soft_cnstrs - 1;
424423
for (;;) {
425424
Z3_model m;

0 commit comments

Comments
 (0)