Skip to content

Commit b3b2683

Browse files
committed
Add test for anonymous local scoping
This creates three source-level variables that are notionally live for the whole function, but then uses the function's dominator tree information to show that they actually have disjoint scopes. Similarly the temporary used to hold a new instance between creation and assignment to a local variable should be given a bounded scope.
1 parent 7eb318e commit b3b2683

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed
329 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
test.class
3+
--show-goto-functions
4+
dead anonlocal::1i
5+
dead anonlocal::2i
6+
dead anonlocal::3a
7+
dead new_tmp0
8+
^EXIT=0$
9+
^SIGNAL=0$
10+
--
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
3+
public class test
4+
{
5+
public static void main(int unknown)
6+
{
7+
int i;
8+
int j;
9+
if(unknown==1)
10+
{
11+
// Check that anonymous locals
12+
// get assigned scopes:
13+
i = 0;
14+
i++;
15+
}
16+
else if(unknown==2)
17+
{
18+
j = 0;
19+
j++;
20+
}
21+
else
22+
{
23+
// Check that temporaries (here
24+
// a new_tmp variable) are treated
25+
// likewise
26+
test t = new test();
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)