From 3667408a5756a47edcc99d38535f544de7e5867a Mon Sep 17 00:00:00 2001 From: grischka Date: Wed, 16 Jan 2008 20:16:35 +0000 Subject: [PATCH] Just warn about unknown directives, define __STDC_VERSION__=199901L --- Changelog | 5 ++++- TODO | 2 ++ alloca86-bt.S | 7 +++++-- alloca86.S | 6 ++++++ tcc.c | 36 ++++++++++++++++++++++-------------- 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/Changelog b/Changelog index 791e83f..8c27cd9 100644 --- a/Changelog +++ b/Changelog @@ -1,7 +1,10 @@ version 0.9.24: +- Just warn about unknown directives, ignore quotes in #error/#warning +- Define __STDC_VERSION__=199901L (477) + - Switch to newer tccpe.c (includes support for resources) -- Handle backslashes within #include, #error, #warning +- Handle backslashes within #include/#error/#warning - Import changesets (part 4) 428,457,460,467: defines for openbsd etc. - Use _WIN32 for a windows hosted tcc and define it for the PE target, otherwise define __unix / __linux (Detlef Riekenberg) diff --git a/TODO b/TODO index cf22bc7..1bd4f2e 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ TODO list: +- FPU st(0) is left unclean (incompatible with optimized gcc/msc code) + - bug with defines: #define spin_lock(lock) do { } while (0) #define wq_spin_lock spin_lock diff --git a/alloca86-bt.S b/alloca86-bt.S index b6071ff..3fa8a53 100644 --- a/alloca86-bt.S +++ b/alloca86-bt.S @@ -1,6 +1,8 @@ /* ---------------------------------------------- */ /* alloca86b.S */ +#include "config.h" + .globl __bound__alloca __bound__alloca: @@ -11,6 +13,7 @@ __bound__alloca: and $-4,%eax jz p6 +#ifdef TCC_TARGET_PE p4: cmp $4096,%eax jle p5 @@ -20,17 +23,17 @@ p4: jmp p4 p5: +#endif + sub %eax,%esp mov %esp,%eax push %edx push %eax - push %ecx push %eax call __bound_new_region add $8, %esp - pop %eax pop %edx diff --git a/alloca86.S b/alloca86.S index c8f0c25..a60b140 100644 --- a/alloca86.S +++ b/alloca86.S @@ -1,6 +1,8 @@ /* ---------------------------------------------- */ /* alloca86.S */ +#include "config.h" + .globl _alloca _alloca: @@ -9,6 +11,8 @@ _alloca: add $3,%eax and $-4,%eax jz p3 + +#ifdef TCC_TARGET_PE p1: cmp $4096,%eax jle p2 @@ -17,6 +21,8 @@ p1: test %eax,(%esp) jmp p1 p2: +#endif + sub %eax,%esp mov %esp,%eax p3: diff --git a/tcc.c b/tcc.c index a8a3f36..1fc2958 100644 --- a/tcc.c +++ b/tcc.c @@ -2307,12 +2307,14 @@ static uint8_t *parse_pp_string(uint8_t *p, #if/#endif */ void preprocess_skip(void) { - int a, start_of_line, c; + int a, start_of_line, c, in_warn_or_error; uint8_t *p; p = file->buf_ptr; - start_of_line = 1; a = 0; +redo_start: + start_of_line = 1; + in_warn_or_error = 0; for(;;) { redo_no_start: c = *p; @@ -2325,10 +2327,9 @@ void preprocess_skip(void) p++; goto redo_no_start; case '\n': - start_of_line = 1; file->line_num++; p++; - goto redo_no_start; + goto redo_start; case '\\': file->buf_ptr = p; c = handle_eob(); @@ -2340,13 +2341,17 @@ void preprocess_skip(void) } p = file->buf_ptr; goto redo_no_start; - /* skip strings */ + /* skip strings */ case '\"': case '\'': + if (in_warn_or_error) + goto _default; p = parse_pp_string(p, c, NULL); break; - /* skip comments */ + /* skip comments */ case '/': + if (in_warn_or_error) + goto _default; file->buf_ptr = p; ch = *p; minp(); @@ -2357,7 +2362,6 @@ void preprocess_skip(void) p = parse_line_comment(p); } break; - case '#': p++; if (start_of_line) { @@ -2371,8 +2375,11 @@ void preprocess_skip(void) a++; else if (tok == TOK_ENDIF) a--; + else if( tok == TOK_ERROR || tok == TOK_WARNING) + in_warn_or_error = 1; } break; +_default: default: p++; break; @@ -3195,7 +3202,7 @@ static void preprocess(int is_bof) to emulate cpp behaviour */ } else { if (!(saved_parse_flags & PARSE_FLAG_ASM_COMMENTS)) - error("invalid preprocessing directive #%s", get_tok_str(tok, &tokc)); + warning("Ignoring unknown preprocessing directive #%s", get_tok_str(tok, &tokc)); } break; } @@ -5464,9 +5471,9 @@ void gen_opl(int op) independent opt */ void gen_opic(int op) { - int c1, c2, t1, t2, n, c; + int c1, c2, t1, t2, n; SValue *v1, *v2; - long long l1, l2, l; + long long l1, l2; typedef unsigned long long U; v1 = vtop - 1; @@ -5533,8 +5540,8 @@ void gen_opic(int op) if (c1 && (op == '+' || op == '&' || op == '^' || op == '|' || op == '*')) { vswap(); - c = c1, c1 = c2, c2 = c; - l = l1, l1 = l2, l2 = l; + c2 = c1; //c = c1, c1 = c2, c2 = c; + l2 = l1; //l = l1, l1 = l2, l2 = l; } /* Filter out NOP operations like x*1, x-0, x&-1... */ if (c2 && (((op == '*' || op == '/' || op == TOK_UDIV || @@ -7650,7 +7657,7 @@ static void unary(void) break; } if (!s) - error("field not found"); + error("field not found: %s", get_tok_str(tok & ~SYM_FIELD, NULL)); /* add field offset to pointer */ vtop->type = char_pointer_type; /* change type to 'char *' */ vpushi(s->c); @@ -9306,7 +9313,7 @@ static void decl(int l) #if 0 { char buf[500]; - type_to_str(buf, sizeof(buf), &type, get_tok_str(v, NULL)); + type_to_str(buf, sizeof(buf), t, get_tok_str(v, NULL)); printf("type = '%s'\n", buf); } #endif @@ -10081,6 +10088,7 @@ TCCState *tcc_new(void) /* standard defines */ tcc_define_symbol(s, "__STDC__", NULL); + tcc_define_symbol(s, "__STDC_VERSION__", "199901L"); #if defined(TCC_TARGET_I386) tcc_define_symbol(s, "__i386__", NULL); #endif