diff options
| author | grischka <grischka> | 2017-07-20 22:21:27 +0200 |
|---|---|---|
| committer | grischka <grischka> | 2017-07-20 22:21:27 +0200 |
| commit | 0cc24d0e8487eaf53bb2849fef7e438a8e8fc94d (patch) | |
| tree | ba77f5e03cb8944f995b103abb668e37a9dceef2 /tests/tests2/96_nodata_wanted.c | |
| parent | ba2b25e4ead7f0037d548289e517b31d29242880 (diff) | |
| download | tinycc-0cc24d0e8487eaf53bb2849fef7e438a8e8fc94d.tar.gz tinycc-0cc24d0e8487eaf53bb2849fef7e438a8e8fc94d.tar.bz2 | |
tcc -dt -run ... : simpler is better
* -dt now with lowercase t
* test snippets now separated by real preprocessor statements
which is valid C also for other compilers
#if defined test_xxx
< test snippet x >
#elif defined test_yyy
< test snippet y >
#elif ...
#endif
* simpler implementation, behaves like -run if no 'test_...' macros
are seen, works with -E too
* for demonstration I combined some of the small tests for errors
and warnings (56..63,74) in "60_errors_and_warnings.c"
Also:
* libtcc.c:
put tcc_preprocess() and tcc_assemble() under the setjmp clause
to let them return to caller after errors. This is for -dt -E.
* tccgen.c:
- get rid of save/restore_parse_state(), macro_ptr is saved
by begin_macro anyway, now line_num too.
- use expr_eq for parsing _Generic's controlling_type
- set nocode_wanted with const_wanted. too, This is to keep
VT_JMP on vtop when parsing preprocessor expressions.
* tccpp.c: tcc -E: suppress trailing whitespace from lines with
comments (that -E removes) such as
NO_GOTPLT_ENTRY,\t /* never generate ... */
Diffstat (limited to 'tests/tests2/96_nodata_wanted.c')
| -rw-r--r-- | tests/tests2/96_nodata_wanted.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/tests2/96_nodata_wanted.c b/tests/tests2/96_nodata_wanted.c index 6f7f3c2..1f022c9 100644 --- a/tests/tests2/96_nodata_wanted.c +++ b/tests/tests2/96_nodata_wanted.c @@ -1,36 +1,35 @@ /*****************************************************************************/ /* test 'nodata_wanted' data output suppression */ -/*-* test 1: initializer not computable 1 */ +#if defined test_static_data_error void foo() { if (1) { - static short w = (int)&foo; /* error */ + static short w = (int)&foo; /* initializer not computable */ } } -/*-* test 2: initializer not computable 2 */ +#elif defined test_static_nodata_error void foo() { if (0) { - static short w = (int)&foo; /* error */ + static short w = (int)&foo; /* initializer not computable */ } } -/*-* test 3: initializer not computable 3 */ +#elif defined test_global_data_error void foo(); -static short w = (int)&foo; /* error */ +static short w = (int)&foo; /* initializer not computable */ -/*-* test 4: 2 cast warnings */ +#elif defined test_local_data_noerror void foo() { - short w = &foo; /* no error */ + short w = &foo; /* 2 cast warnings */ } -/*-* test 5; nodata_wanted test */ +#elif defined test_data_suppression #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 ASMLABELS(s) \ + __asm__(".global d"#s",t"#s"\n.data\nd"#s":\n.text\nt"#s":\n") #define PROG \ static void *p = (void*)&main;\ @@ -47,28 +46,29 @@ void foo() { int main() { + extern char ds1[],ts1[]; + extern char ds2[],ts2[]; + extern char de1[],te1[]; + extern char de2[],te2[]; + printf("suppression off\n"); - DATA_LBL(s1); if (1) { + ASMLABELS(s1); PROG + ASMLABELS(e1); } - 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(" text length is %s\n", te1 - ts1 ? "not 0":"0"); printf("suppression on\n"); - DATA_LBL(s2); if (0) { + ASMLABELS(s2); PROG + ASMLABELS(e2); } - DATA_LBL(e2); printf(" data length is %x\n", de2 - ds2); - //printf(" text length is %X\n", te2 - ts2); + printf(" text length is %X\n", te2 - ts2); return 0; } -/*-* test 6: some test */ -int main() -{ - return 34; -} +#endif |
