Skip to content

Commit 8fddc94

Browse files
committed
Add tests
1 parent b43670b commit 8fddc94

16 files changed

+522
-0
lines changed
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
main: (args) =
2+
{
3+
a := 1;
4+
b := 2;
5+
c := 3;
6+
d := 4;
7+
8+
{
9+
p : *int;
10+
11+
// no initialization in selection_node
12+
if args.argc > 20 {
13+
c = 20;
14+
} else if args.argc > 10 {
15+
c = 10;
16+
} else {
17+
if args.argc % 2 {
18+
b = 2;
19+
} else {
20+
b = 1;
21+
}
22+
}
23+
24+
// initialization in first if condition
25+
if p = b& {
26+
p = a&;
27+
} else if args.argc == 3 {
28+
p = b&;
29+
if args.argc == 2 {
30+
p = c&;
31+
} else {
32+
if b > 0 {
33+
p = a&;
34+
}
35+
else {
36+
p = d&;
37+
}
38+
}
39+
} else {
40+
p = c&;
41+
}
42+
43+
std::cout << p* << std::endl;
44+
}
45+
46+
{
47+
p : *int;
48+
49+
// initialization in:
50+
// - first if branch
51+
// - second if condition
52+
if args.argc == 3 {
53+
p = a&;
54+
} else if p = b& {
55+
p = b&;
56+
if args.argc == 2 {
57+
p = c&;
58+
} else {
59+
if b > 0 {
60+
p = a&;
61+
}
62+
else {
63+
p = d&;
64+
}
65+
}
66+
} else {
67+
p = c&;
68+
}
69+
70+
std::cout << p* << std::endl;
71+
}
72+
73+
{
74+
p : *int;
75+
76+
// initialization in:
77+
// - first if branch
78+
// - second if branch in nested if condition (first if)
79+
// - else branch
80+
if args.argc == 3 {
81+
p = a&;
82+
} else if args.argc == 2 {
83+
if p = b& {
84+
p = c&;
85+
} else {
86+
if b > 0 {
87+
p = a&;
88+
}
89+
else {
90+
p = d&;
91+
}
92+
}
93+
} else {
94+
p = c&;
95+
}
96+
97+
std::cout << p* << std::endl;
98+
}
99+
100+
{
101+
p : *int;
102+
103+
// initialization in:
104+
// - first if branch
105+
// - second if branch in nested if:
106+
// - first branch
107+
// - second branch in nested if condition (first if)
108+
// - else branch
109+
if args.argc == 3 {
110+
p = a&;
111+
} else if args.argc == 2 {
112+
if b > 0 {
113+
p = c&;
114+
} else {
115+
if p = b& {
116+
p = a&;
117+
}
118+
else {
119+
p = d&;
120+
}
121+
p* = 42;
122+
}
123+
p* = 24;
124+
} else {
125+
p = c&;
126+
}
127+
128+
std::cout << p* << std::endl;
129+
}
130+
131+
{
132+
p : *int;
133+
134+
// initialization in:
135+
// - first if branch
136+
// - second if branch in nested if:
137+
// - first branch
138+
// - second branch in nested if:
139+
// - first if branch
140+
// - second if condition
141+
// - else branch
142+
if args.argc == 3 {
143+
p = a&;
144+
} else if args.argc == 2 {
145+
if b > 0 {
146+
p = c&;
147+
} else {
148+
if b > 2 {
149+
p = a&;
150+
}
151+
else if p = b& {
152+
d = p*;
153+
}
154+
else {
155+
p = d&;
156+
}
157+
}
158+
} else {
159+
p = c&;
160+
}
161+
162+
std::cout << p* << std::endl;
163+
}
164+
165+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
main: (args) = {
2+
p : *int;
3+
4+
a := 1;
5+
b := 2;
6+
c := 3;
7+
d := 4;
8+
9+
if args.argc == 3 {
10+
p = a&;
11+
} else if b > 2 {
12+
if args.argc == 2 {
13+
p = c&;
14+
} else {
15+
if b > 0 {
16+
p = a&;
17+
}
18+
else {
19+
p = d&;
20+
}
21+
}
22+
} else {
23+
// p = c&;
24+
}
25+
26+
std::cout << p* << std::endl;
27+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
main: (args) =
2+
{
3+
a := 1;
4+
b := 2;
5+
c := 3;
6+
d := 4;
7+
8+
{
9+
p : *int;
10+
11+
// no initialization in selection_node
12+
if args.argc > 20 {
13+
c = 20;
14+
} else if args.argc > 10 {
15+
c = 10;
16+
} else {
17+
if args.argc % 2 {
18+
b = 2;
19+
} else {
20+
b = 1;
21+
}
22+
}
23+
24+
// initialization in:
25+
// - first if branch
26+
// - second if branch in nested if:
27+
// - first branch
28+
// - second branch in nested if:
29+
// - first if branch
30+
// - else branch
31+
// - else branch
32+
if args.argc == 3 {
33+
p = a&;
34+
} else if args.argc == 2 {
35+
if b > 0 {
36+
p = c&;
37+
} else {
38+
if b > 2 {
39+
p = a&;
40+
}
41+
else {
42+
p = d&;
43+
}
44+
}
45+
} else {
46+
p = c&;
47+
}
48+
49+
std::cout << p* << std::endl;
50+
}
51+
52+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3

regression-tests/test-results/apple-clang-14/pure2-nested-ifs.cpp.output

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3

regression-tests/test-results/clang-12/pure2-nested-ifs.cpp.output

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3

regression-tests/test-results/gcc-10/pure2-nested-ifs.cpp.output

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3

regression-tests/test-results/msvc-2022/pure2-nested-ifs.cpp.output

Whitespace-only changes.

0 commit comments

Comments
 (0)