Support for static variables complete
git-svn-id: http://picoc.googlecode.com/svn/trunk@547 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
cab5e8b2d8
commit
a2cb2e2efd
26
tests/51_static.c
Normal file
26
tests/51_static.c
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static int fred = 1234;
|
||||||
|
static int joe;
|
||||||
|
|
||||||
|
void henry()
|
||||||
|
{
|
||||||
|
static int fred = 4567;
|
||||||
|
|
||||||
|
printf("%d\n", fred);
|
||||||
|
fred++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
printf("%d\n", fred);
|
||||||
|
henry();
|
||||||
|
henry();
|
||||||
|
henry();
|
||||||
|
henry();
|
||||||
|
printf("%d\n", fred);
|
||||||
|
fred = 8901;
|
||||||
|
joe = 2345;
|
||||||
|
printf("%d\n", fred);
|
||||||
|
printf("%d\n", joe);
|
||||||
|
}
|
8
tests/51_static.expect
Normal file
8
tests/51_static.expect
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
1234
|
||||||
|
4567
|
||||||
|
4568
|
||||||
|
4569
|
||||||
|
4570
|
||||||
|
1234
|
||||||
|
8901
|
||||||
|
2345
|
|
@ -31,10 +31,10 @@ TESTS= 00_assignment.test \
|
||||||
31_args.test \
|
31_args.test \
|
||||||
32_led.test \
|
32_led.test \
|
||||||
33_ternary_op.test \
|
33_ternary_op.test \
|
||||||
34_array_assignment.test \
|
34_array_assignment.test \
|
||||||
35_sizeof.test \
|
35_sizeof.test \
|
||||||
36_array_initialisers.test \
|
36_array_initialisers.test \
|
||||||
37_sprintf.test \
|
37_sprintf.test \
|
||||||
38_multiple_array_index.test \
|
38_multiple_array_index.test \
|
||||||
39_typedef.test \
|
39_typedef.test \
|
||||||
40_stdio.test \
|
40_stdio.test \
|
||||||
|
@ -45,7 +45,8 @@ TESTS= 00_assignment.test \
|
||||||
47_switch_return.test \
|
47_switch_return.test \
|
||||||
48_nested_break.test \
|
48_nested_break.test \
|
||||||
49_bracket_evaluation.test \
|
49_bracket_evaluation.test \
|
||||||
50_logical_second_arg.test
|
50_logical_second_arg.test \
|
||||||
|
51_static.test
|
||||||
|
|
||||||
%.test: %.expect %.c
|
%.test: %.expect %.c
|
||||||
@echo Test: $*...
|
@echo Test: $*...
|
||||||
|
|
Loading…
Reference in a new issue