scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit a86e1949ea1d59dcdf1e89ecdf0e2b53865efc46
parent 5c3dd68b9c8862b5eee0f9b9f08928c702e7c607
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 15 Aug 2015 21:43:36 +0200

Add basic test for break and continue statements

This patch also adds a #line directive in test006.c
to aovid the problems related to the change in the
size of the output (different lines in the warnings).

Diffstat:
Mcc1/tests/test006.c | 8+++++---
Acc1/tests/test010.c | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 99 insertions(+), 3 deletions(-)

diff --git a/cc1/tests/test006.c b/cc1/tests/test006.c @@ -2,9 +2,9 @@ name: TEST006 description: Basic test for if output: -test006.c:42: warning: conditional expression is constant -test006.c:44: warning: conditional expression is constant -test006.c:47: warning: conditional expression is constant +test006.c:6: warning: conditional expression is constant +test006.c:8: warning: conditional expression is constant +test006.c:11: warning: conditional expression is constant G1 M c F1 G2 F1 main @@ -36,6 +36,8 @@ L3 char c; +#line 1 + int main() { diff --git a/cc1/tests/test010.c b/cc1/tests/test010.c @@ -0,0 +1,94 @@ +/* +name: TEST010 +description: Test for continue and break statements +output: +test010.c:9: warning: conditional expression is constant +test010.c:11: warning: conditional expression is constant +test010.c:31: warning: conditional expression is constant +F1 +G1 F1 main +{ +- +A2 I x + A2 #I0 :I + j L5 + d +L3 + j L4 +L5 + j L3 #I1 + b +L4 + j L8 + d +L6 + j L9 A2 #I5 !I + j L7 +L9 + A2 A2 #I1 +I :I + j L6 +L8 + j L6 #I1 + b +L7 + + j L12 + d +L10 + j L13 A2 #IA !I + j L11 +L13 + A2 A2 #I1 +I :I + j L10 + +L12 + j L10 + b +L11 + d +L14 + j L16 A2 #IF !I + j L15 +L16 + A2 A2 #I1 +I :I + j L14 + j L14 #I1 + b +L15 + yI A2 #IF -I +} +*/ + +#line 1 + +int +main() +{ + int x; + + x = 0; + while(1) + break; + while(1) { + if (x == 5) { + break; + } + x = x + 1; + continue; + } + for (;;) { + if (x == 10) { + break; + } + x = x + 1; + continue; + } + do { + if (x == 15) { + break; + } + x = x + 1; + continue; + } while(1); + return x - 15; +}