Skip to content

Commit

Permalink
Regression tests for flowgraph construction bug on ExprWhile.
Browse files Browse the repository at this point in the history
  • Loading branch information
pnkfelix committed Jun 18, 2014
1 parent 373b0fc commit 3ddb987
Show file tree
Hide file tree
Showing 7 changed files with 444 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/test/run-make/graphviz-flowgraph/Makefile
Expand Up @@ -2,7 +2,8 @@

FILES=f00.rs f01.rs f02.rs f03.rs f04.rs f05.rs f06.rs f07.rs \
f08.rs f09.rs f10.rs f11.rs f12.rs f13.rs f14.rs f15.rs \
f16.rs f17.rs f18.rs f19.rs f20.rs f21.rs f22.rs
f16.rs f17.rs f18.rs f19.rs f20.rs f21.rs f22.rs f23.rs \
f24.rs f25.rs


# all: $(patsubst %.rs,$(TMPDIR)/%.dot,$(FILES)) $(patsubst %.rs,$(TMPDIR)/%.pp,$(FILES))
Expand Down
93 changes: 93 additions & 0 deletions src/test/run-make/graphviz-flowgraph/f23.dot-expected.dot
@@ -0,0 +1,93 @@
digraph block {
N0[label="entry"];
N1[label="exit"];
N2[label="expr 23"];
N3[label="local mut x"];
N4[label="expr 23"];
N5[label="local mut y"];
N6[label="expr 23"];
N7[label="local mut z"];
N8[label="(dummy_node)"];
N9[label="expr x"];
N10[label="expr 0"];
N11[label="expr x > 0"];
N12[label="expr while x > 0 {\l x -= 1;\l while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"];
N13[label="expr 1"];
N14[label="expr x"];
N15[label="expr x -= 1"];
N16[label="(dummy_node)"];
N17[label="expr y"];
N18[label="expr 0"];
N19[label="expr y > 0"];
N20[label="expr while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l"];
N21[label="expr 1"];
N22[label="expr y"];
N23[label="expr y -= 1"];
N24[label="(dummy_node)"];
N25[label="expr z"];
N26[label="expr 0"];
N27[label="expr z > 0"];
N28[label="expr while z > 0 { z -= 1; }"];
N29[label="expr 1"];
N30[label="expr z"];
N31[label="expr z -= 1"];
N32[label="block { z -= 1; }"];
N33[label="expr x"];
N34[label="expr 10"];
N35[label="expr x > 10"];
N36[label="expr return"];
N37[label="(dummy_node)"];
N38[label="expr \"unreachable\""];
N39[label="block { return; \"unreachable\"; }"];
N40[label="expr if x > 10 { return; \"unreachable\"; }"];
N41[label="block { y -= 1; while z > 0 { z -= 1; } if x > 10 { return; \"unreachable\"; } }"];
N42[label="block {\l x -= 1;\l while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"];
N43[label="block {\l let mut x = 23;\l let mut y = 23;\l let mut z = 23;\l while x > 0 {\l x -= 1;\l while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l }\l}\l"];
N0 -> N2;
N2 -> N3;
N3 -> N4;
N4 -> N5;
N5 -> N6;
N6 -> N7;
N7 -> N8;
N8 -> N9;
N9 -> N10;
N10 -> N11;
N11 -> N12;
N11 -> N13;
N13 -> N14;
N14 -> N15;
N15 -> N16;
N16 -> N17;
N17 -> N18;
N18 -> N19;
N19 -> N20;
N19 -> N21;
N21 -> N22;
N22 -> N23;
N23 -> N24;
N24 -> N25;
N25 -> N26;
N26 -> N27;
N27 -> N28;
N27 -> N29;
N29 -> N30;
N30 -> N31;
N31 -> N32;
N32 -> N24;
N28 -> N33;
N33 -> N34;
N34 -> N35;
N35 -> N36;
N36 -> N1[label="exiting scope_0 expr while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr while x > 0 {\l x -= 1;\l while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"];
N37 -> N38;
N38 -> N39;
N35 -> N40;
N39 -> N40;
N40 -> N41;
N41 -> N16;
N20 -> N42;
N42 -> N8;
N12 -> N43;
N43 -> N1;
}
31 changes: 31 additions & 0 deletions src/test/run-make/graphviz-flowgraph/f23.rs
@@ -0,0 +1,31 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[allow(unreachable_code)]
pub fn expr_while_23() {
let mut x = 23;
let mut y = 23;
let mut z = 23;

while x > 0 {
x -= 1;

while y > 0 {
y -= 1;

while z > 0 { z -= 1; }

if x > 10 {
return;
"unreachable";
}
}
}
}
123 changes: 123 additions & 0 deletions src/test/run-make/graphviz-flowgraph/f24.dot-expected.dot
@@ -0,0 +1,123 @@
digraph block {
N0[label="entry"];
N1[label="exit"];
N2[label="expr 24"];
N3[label="local mut x"];
N4[label="expr 24"];
N5[label="local mut y"];
N6[label="expr 24"];
N7[label="local mut z"];
N8[label="(dummy_node)"];
N9[label="expr loop {\l if x == 0 { break ; \"unreachable\"; }\l x -= 1;\l loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"];
N10[label="expr x"];
N11[label="expr 0"];
N12[label="expr x == 0"];
N13[label="expr break"];
N14[label="(dummy_node)"];
N15[label="expr \"unreachable\""];
N16[label="block { break ; \"unreachable\"; }"];
N17[label="expr if x == 0 { break ; \"unreachable\"; }"];
N18[label="expr 1"];
N19[label="expr x"];
N20[label="expr x -= 1"];
N21[label="(dummy_node)"];
N22[label="expr loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l"];
N23[label="expr y"];
N24[label="expr 0"];
N25[label="expr y == 0"];
N26[label="expr break"];
N27[label="(dummy_node)"];
N28[label="expr \"unreachable\""];
N29[label="block { break ; \"unreachable\"; }"];
N30[label="expr if y == 0 { break ; \"unreachable\"; }"];
N31[label="expr 1"];
N32[label="expr y"];
N33[label="expr y -= 1"];
N34[label="(dummy_node)"];
N35[label="expr loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }"];
N36[label="expr z"];
N37[label="expr 0"];
N38[label="expr z == 0"];
N39[label="expr break"];
N40[label="(dummy_node)"];
N41[label="expr \"unreachable\""];
N42[label="block { break ; \"unreachable\"; }"];
N43[label="expr if z == 0 { break ; \"unreachable\"; }"];
N44[label="expr 1"];
N45[label="expr z"];
N46[label="expr z -= 1"];
N47[label="block { if z == 0 { break ; \"unreachable\"; } z -= 1; }"];
N48[label="expr x"];
N49[label="expr 10"];
N50[label="expr x > 10"];
N51[label="expr return"];
N52[label="(dummy_node)"];
N53[label="expr \"unreachable\""];
N54[label="block { return; \"unreachable\"; }"];
N55[label="expr if x > 10 { return; \"unreachable\"; }"];
N56[label="block {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l"];
N57[label="block {\l if x == 0 { break ; \"unreachable\"; }\l x -= 1;\l loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"];
N58[label="block {\l let mut x = 24;\l let mut y = 24;\l let mut z = 24;\l loop {\l if x == 0 { break ; \"unreachable\"; }\l x -= 1;\l loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l }\l}\l"];
N0 -> N2;
N2 -> N3;
N3 -> N4;
N4 -> N5;
N5 -> N6;
N6 -> N7;
N7 -> N8;
N8 -> N10;
N10 -> N11;
N11 -> N12;
N12 -> N13;
N13 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0 { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0 { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 0 { break ; \"unreachable\"; }\l x -= 1;\l loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"];
N14 -> N15;
N15 -> N16;
N12 -> N17;
N16 -> N17;
N17 -> N18;
N18 -> N19;
N19 -> N20;
N20 -> N21;
N21 -> N23;
N23 -> N24;
N24 -> N25;
N25 -> N26;
N26 -> N22[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0 { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0 { break ; \"unreachable\"; },\lexiting scope_5 block {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l"];
N27 -> N28;
N28 -> N29;
N25 -> N30;
N29 -> N30;
N30 -> N31;
N31 -> N32;
N32 -> N33;
N33 -> N34;
N34 -> N36;
N36 -> N37;
N37 -> N38;
N38 -> N39;
N39 -> N35[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0 { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0 { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0 { break ; \"unreachable\"; } z -= 1; }"];
N40 -> N41;
N41 -> N42;
N38 -> N43;
N42 -> N43;
N43 -> N44;
N44 -> N45;
N45 -> N46;
N46 -> N47;
N47 -> N34;
N35 -> N48;
N48 -> N49;
N49 -> N50;
N50 -> N51;
N51 -> N1[label="exiting scope_0 expr loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr loop {\l if x == 0 { break ; \"unreachable\"; }\l x -= 1;\l loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"];
N52 -> N53;
N53 -> N54;
N50 -> N55;
N54 -> N55;
N55 -> N56;
N56 -> N21;
N22 -> N57;
N57 -> N8;
N9 -> N58;
N58 -> N1;
}
36 changes: 36 additions & 0 deletions src/test/run-make/graphviz-flowgraph/f24.rs
@@ -0,0 +1,36 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[allow(unreachable_code)]
pub fn expr_while_24() {
let mut x = 24;
let mut y = 24;
let mut z = 24;

loop {
if x == 0 { break; "unreachable"; }
x -= 1;

loop {
if y == 0 { break; "unreachable"; }
y -= 1;

loop {
if z == 0 { break; "unreachable"; }
z -= 1;
}

if x > 10 {
return;
"unreachable";
}
}
}
}

0 comments on commit 3ddb987

Please sign in to comment.