scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 05da06ee7b432a9a4a9f14108cece51f6f557114
parent ffbb1e8dedda4975725bfa5dc501cfbf589301b9
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 25 Aug 2015 15:28:55 +0200

Add basic test for pointers

Diffstat:
cc1/tests/test016.c | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+), 0 deletions(-)

diff --git a/cc1/tests/test016.c b/cc1/tests/test016.c @@ -0,0 +1,94 @@ +/* +name: TEST016 +description: Basic pointer test +output: +test016.c:43: error: redefinition of 'func2' +test016.c:47: error: incompatible types when assigning +G1 I g +F1 +G2 F1 func1 +{ +- +A2 I x +A4 P p + G1 #I1 :I + A2 #I1 :I + A4 A2 'P :P + A4 @I #I0 :I + j L5 A2 #I0 =I + yI #I1 +L5 + A4 G1 'P :P + A4 @I #I0 :I + j L6 A4 #I0 IP !I + yI #I1 +L6 + yI #I0 +} +G3 F1 func2 +{ +- +A1 I x +A2 P p +A4 P pp + A1 #I1 :I + A2 A1 'P :P + A4 A2 'P :P + j L5 A2 #I0 IP =I + A4 @P @I #I0 :I +L5 + A2 #I0 IP :P + yI A1 +} +???? +*/ + +#line 1 + +int g; + +int +func1(void) +{ + int x; + int *p; + + g = 1; + x = 1; + p = &x; + *p = 0; + if (x) + return 1; + + p = &g; + *p = 0; + if (p == 0) + return 1; + return 0; +} + +int +func2(void) +{ + int x; + int *p; + int **pp; + + x = 1; + p = &x; + pp = &p; + if (p != 0) + **pp = 0; + p = 0; + return x; +} + +int +func2(void) +{ + char c; + int *p; + + p = &c; + return *p; +}