This source file includes following definitions.
- function
- f
- test_assume_expressions
- test_assume_optimization
- test_assume_noreturn
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <config.h>
21
22 #include "verify.h"
23
24 #ifndef EXP_FAIL
25 # define EXP_FAIL 0
26 #endif
27
28
29
30 int gx;
31 enum { A, B, C };
32
33 #if EXP_FAIL == 1
34 verify (gx >= 0);
35 #endif
36 verify (C == 2);
37 #if EXP_FAIL == 2
38 verify (1 + 1 == 3);
39 #endif
40 verify (1 == 1); verify (1 == 1);
41
42 enum
43 {
44 item = verify_expr (1 == 1, 10 * 0 + 17)
45 };
46
47 static int
48 function (int n)
49 {
50 #if EXP_FAIL == 3
51 verify (n >= 0);
52 #endif
53 verify (C == 2);
54 #if EXP_FAIL == 4
55 verify (1 + 1 == 3);
56 #endif
57 verify (1 == 1); verify (1 == 1);
58
59 if (n)
60 return ((void) verify_expr (1 == 1, 1), verify_expr (1 == 1, 8));
61 #if EXP_FAIL == 5
62 return verify_expr (1 == 2, 5);
63 #endif
64 return 0;
65 }
66
67
68
69 static int
70 f (int a)
71 {
72 return a;
73 }
74
75 typedef struct { unsigned int context : 4; unsigned int halt : 1; } state;
76
77 void test_assume_expressions (state *s);
78 int test_assume_optimization (int x);
79 _Noreturn void test_assume_noreturn (void);
80
81 void
82 test_assume_expressions (state *s)
83 {
84
85
86 assume (f (1));
87
88 assume (s->halt);
89 }
90
91 int
92 test_assume_optimization (int x)
93 {
94
95
96
97
98
99 assume (x >= 4);
100 return (x > 1 ? x + 3 : 2 * x + 10);
101 }
102
103 _Noreturn void
104 test_assume_noreturn (void)
105 {
106
107
108 assume (0);
109 }
110
111
112 int
113 main (void)
114 {
115 state s = { 0, 1 };
116 test_assume_expressions (&s);
117 test_assume_optimization (5);
118 return !(function (0) == 0 && function (1) == 8);
119 }