diff options
| author | grischka <grischka> | 2017-07-16 12:10:00 +0200 |
|---|---|---|
| committer | grischka <grischka> | 2017-07-16 12:10:00 +0200 |
| commit | 7f1ab9b1e111b9ea9261eec4b7c6fb0f42591eef (patch) | |
| tree | 303c1656ec1a7023247fad8047f3b86acd3542c6 /tests/tests2/96_nodata_wanted.c | |
| parent | 69a137ff889f552b3ce58b861f3f0601c1818d6b (diff) | |
| download | tinycc-7f1ab9b1e111b9ea9261eec4b7c6fb0f42591eef.tar.gz tinycc-7f1ab9b1e111b9ea9261eec4b7c6fb0f42591eef.tar.bz2 | |
tccgen: nodata_wanted
The existing variable 'nocode_wanted' is now used to control
output of static data too. So...
(nocode_wanted == 0)
code and data (normal within functions)
(nocode_wanted < 0)
means: no code, but data (global or static data)
(nocode_wanted > 0)
means: no code and no data (code and data suppressed)
(nocode_wanted & 0xC0000000)
means: we're in declaration of static data
Also: new option '-dT' to be used with -run
tcc -dT -run file.c
This will look in file.c for certain comment-boundaries:
/*-* test-xxx: ...some description */
and then for each test below run it from memory. This way
various features and error messages can be tested with one
single file. See 96_nodata_wanted.c for an example.
Also: tccgen.c: one more bitfield fix
Diffstat (limited to 'tests/tests2/96_nodata_wanted.c')
| -rw-r--r-- | tests/tests2/96_nodata_wanted.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/tests2/96_nodata_wanted.c b/tests/tests2/96_nodata_wanted.c new file mode 100644 index 0000000..6f7f3c2 --- /dev/null +++ b/tests/tests2/96_nodata_wanted.c @@ -0,0 +1,74 @@ +/*****************************************************************************/ +/* test 'nodata_wanted' data output suppression */ + +/*-* test 1: initializer not computable 1 */ +void foo() { + if (1) { + static short w = (int)&foo; /* error */ + } +} + +/*-* test 2: initializer not computable 2 */ +void foo() { + if (0) { + static short w = (int)&foo; /* error */ + } +} + +/*-* test 3: initializer not computable 3 */ +void foo(); +static short w = (int)&foo; /* error */ + + +/*-* test 4: 2 cast warnings */ +void foo() { + short w = &foo; /* no error */ +} + +/*-* test 5; nodata_wanted test */ +#include <stdio.h> + +#define DATA_LBL(s) \ + __asm__(".global d"#s",t"#s"\n.data\nd"#s":\n.text\nt"#s":\n"); \ + extern char d##s[],t##s[]; + +#define PROG \ + static void *p = (void*)&main;\ + static char cc[] = "static string";\ + static double d = 8.0;\ + static struct __attribute__((packed)) {\ + unsigned x : 12;\ + unsigned char y : 7;\ + unsigned z : 28, a: 4, b: 5;\ + } s = { 0x333,0x44,0x555555,6,7 };\ + printf(" static data: %d - %.1f - %.1f - %s - %s\n",\ + sizeof 8.0, 8.0, d, __FUNCTION__, cc);\ + printf(" static bitfields: %x %x %x %x %x\n", s.x, s.y, s.z, s.a, s.b); + +int main() +{ + printf("suppression off\n"); + DATA_LBL(s1); + if (1) { + PROG + } + DATA_LBL(e1); + printf(" data length is %s\n", de1 - ds1 ? "not 0":"0"); + //printf(" text length is %s\n", te1 - ts1 ? "not 0":"0"); + + printf("suppression on\n"); + DATA_LBL(s2); + if (0) { + PROG + } + DATA_LBL(e2); + printf(" data length is %x\n", de2 - ds2); + //printf(" text length is %X\n", te2 - ts2); + return 0; +} + +/*-* test 6: some test */ +int main() +{ + return 34; +} |
