mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-05 04:40:06 +08:00
0cc24d0e84
* -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 ... */
75 lines
1.8 KiB
C
75 lines
1.8 KiB
C
/*****************************************************************************/
|
|
/* test 'nodata_wanted' data output suppression */
|
|
|
|
#if defined test_static_data_error
|
|
void foo() {
|
|
if (1) {
|
|
static short w = (int)&foo; /* initializer not computable */
|
|
}
|
|
}
|
|
|
|
#elif defined test_static_nodata_error
|
|
void foo() {
|
|
if (0) {
|
|
static short w = (int)&foo; /* initializer not computable */
|
|
}
|
|
}
|
|
|
|
#elif defined test_global_data_error
|
|
void foo();
|
|
static short w = (int)&foo; /* initializer not computable */
|
|
|
|
|
|
#elif defined test_local_data_noerror
|
|
void foo() {
|
|
short w = &foo; /* 2 cast warnings */
|
|
}
|
|
|
|
#elif defined test_data_suppression
|
|
#include <stdio.h>
|
|
|
|
#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;\
|
|
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()
|
|
{
|
|
extern char ds1[],ts1[];
|
|
extern char ds2[],ts2[];
|
|
extern char de1[],te1[];
|
|
extern char de2[],te2[];
|
|
|
|
printf("suppression off\n");
|
|
if (1) {
|
|
ASMLABELS(s1);
|
|
PROG
|
|
ASMLABELS(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");
|
|
if (0) {
|
|
ASMLABELS(s2);
|
|
PROG
|
|
ASMLABELS(e2);
|
|
}
|
|
printf(" data length is %x\n", de2 - ds2);
|
|
printf(" text length is %X\n", te2 - ts2);
|
|
return 0;
|
|
}
|
|
|
|
#endif
|