Just warn about unknown directives, define __STDC_VERSION__=199901L

This commit is contained in:
grischka 2008-01-16 20:16:35 +00:00
parent 5342b32eef
commit 3667408a57
5 changed files with 39 additions and 17 deletions

View file

@ -1,7 +1,10 @@
version 0.9.24: 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) - 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. - 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, - Use _WIN32 for a windows hosted tcc and define it for the PE target,
otherwise define __unix / __linux (Detlef Riekenberg) otherwise define __unix / __linux (Detlef Riekenberg)

2
TODO
View file

@ -1,5 +1,7 @@
TODO list: TODO list:
- FPU st(0) is left unclean (incompatible with optimized gcc/msc code)
- bug with defines: - bug with defines:
#define spin_lock(lock) do { } while (0) #define spin_lock(lock) do { } while (0)
#define wq_spin_lock spin_lock #define wq_spin_lock spin_lock

View file

@ -1,6 +1,8 @@
/* ---------------------------------------------- */ /* ---------------------------------------------- */
/* alloca86b.S */ /* alloca86b.S */
#include "config.h"
.globl __bound__alloca .globl __bound__alloca
__bound__alloca: __bound__alloca:
@ -11,6 +13,7 @@ __bound__alloca:
and $-4,%eax and $-4,%eax
jz p6 jz p6
#ifdef TCC_TARGET_PE
p4: p4:
cmp $4096,%eax cmp $4096,%eax
jle p5 jle p5
@ -20,17 +23,17 @@ p4:
jmp p4 jmp p4
p5: p5:
#endif
sub %eax,%esp sub %eax,%esp
mov %esp,%eax mov %esp,%eax
push %edx push %edx
push %eax push %eax
push %ecx push %ecx
push %eax push %eax
call __bound_new_region call __bound_new_region
add $8, %esp add $8, %esp
pop %eax pop %eax
pop %edx pop %edx

View file

@ -1,6 +1,8 @@
/* ---------------------------------------------- */ /* ---------------------------------------------- */
/* alloca86.S */ /* alloca86.S */
#include "config.h"
.globl _alloca .globl _alloca
_alloca: _alloca:
@ -9,6 +11,8 @@ _alloca:
add $3,%eax add $3,%eax
and $-4,%eax and $-4,%eax
jz p3 jz p3
#ifdef TCC_TARGET_PE
p1: p1:
cmp $4096,%eax cmp $4096,%eax
jle p2 jle p2
@ -17,6 +21,8 @@ p1:
test %eax,(%esp) test %eax,(%esp)
jmp p1 jmp p1
p2: p2:
#endif
sub %eax,%esp sub %eax,%esp
mov %esp,%eax mov %esp,%eax
p3: p3:

36
tcc.c
View file

@ -2307,12 +2307,14 @@ static uint8_t *parse_pp_string(uint8_t *p,
#if/#endif */ #if/#endif */
void preprocess_skip(void) void preprocess_skip(void)
{ {
int a, start_of_line, c; int a, start_of_line, c, in_warn_or_error;
uint8_t *p; uint8_t *p;
p = file->buf_ptr; p = file->buf_ptr;
start_of_line = 1;
a = 0; a = 0;
redo_start:
start_of_line = 1;
in_warn_or_error = 0;
for(;;) { for(;;) {
redo_no_start: redo_no_start:
c = *p; c = *p;
@ -2325,10 +2327,9 @@ void preprocess_skip(void)
p++; p++;
goto redo_no_start; goto redo_no_start;
case '\n': case '\n':
start_of_line = 1;
file->line_num++; file->line_num++;
p++; p++;
goto redo_no_start; goto redo_start;
case '\\': case '\\':
file->buf_ptr = p; file->buf_ptr = p;
c = handle_eob(); c = handle_eob();
@ -2340,13 +2341,17 @@ void preprocess_skip(void)
} }
p = file->buf_ptr; p = file->buf_ptr;
goto redo_no_start; goto redo_no_start;
/* skip strings */ /* skip strings */
case '\"': case '\"':
case '\'': case '\'':
if (in_warn_or_error)
goto _default;
p = parse_pp_string(p, c, NULL); p = parse_pp_string(p, c, NULL);
break; break;
/* skip comments */ /* skip comments */
case '/': case '/':
if (in_warn_or_error)
goto _default;
file->buf_ptr = p; file->buf_ptr = p;
ch = *p; ch = *p;
minp(); minp();
@ -2357,7 +2362,6 @@ void preprocess_skip(void)
p = parse_line_comment(p); p = parse_line_comment(p);
} }
break; break;
case '#': case '#':
p++; p++;
if (start_of_line) { if (start_of_line) {
@ -2371,8 +2375,11 @@ void preprocess_skip(void)
a++; a++;
else if (tok == TOK_ENDIF) else if (tok == TOK_ENDIF)
a--; a--;
else if( tok == TOK_ERROR || tok == TOK_WARNING)
in_warn_or_error = 1;
} }
break; break;
_default:
default: default:
p++; p++;
break; break;
@ -3195,7 +3202,7 @@ static void preprocess(int is_bof)
to emulate cpp behaviour */ to emulate cpp behaviour */
} else { } else {
if (!(saved_parse_flags & PARSE_FLAG_ASM_COMMENTS)) 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; break;
} }
@ -5464,9 +5471,9 @@ void gen_opl(int op)
independent opt */ independent opt */
void gen_opic(int op) void gen_opic(int op)
{ {
int c1, c2, t1, t2, n, c; int c1, c2, t1, t2, n;
SValue *v1, *v2; SValue *v1, *v2;
long long l1, l2, l; long long l1, l2;
typedef unsigned long long U; typedef unsigned long long U;
v1 = vtop - 1; v1 = vtop - 1;
@ -5533,8 +5540,8 @@ void gen_opic(int op)
if (c1 && (op == '+' || op == '&' || op == '^' || if (c1 && (op == '+' || op == '&' || op == '^' ||
op == '|' || op == '*')) { op == '|' || op == '*')) {
vswap(); vswap();
c = c1, c1 = c2, c2 = c; c2 = c1; //c = c1, c1 = c2, c2 = c;
l = l1, l1 = l2, l2 = l; l2 = l1; //l = l1, l1 = l2, l2 = l;
} }
/* Filter out NOP operations like x*1, x-0, x&-1... */ /* Filter out NOP operations like x*1, x-0, x&-1... */
if (c2 && (((op == '*' || op == '/' || op == TOK_UDIV || if (c2 && (((op == '*' || op == '/' || op == TOK_UDIV ||
@ -7650,7 +7657,7 @@ static void unary(void)
break; break;
} }
if (!s) if (!s)
error("field not found"); error("field not found: %s", get_tok_str(tok & ~SYM_FIELD, NULL));
/* add field offset to pointer */ /* add field offset to pointer */
vtop->type = char_pointer_type; /* change type to 'char *' */ vtop->type = char_pointer_type; /* change type to 'char *' */
vpushi(s->c); vpushi(s->c);
@ -9306,7 +9313,7 @@ static void decl(int l)
#if 0 #if 0
{ {
char buf[500]; 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); printf("type = '%s'\n", buf);
} }
#endif #endif
@ -10081,6 +10088,7 @@ TCCState *tcc_new(void)
/* standard defines */ /* standard defines */
tcc_define_symbol(s, "__STDC__", NULL); tcc_define_symbol(s, "__STDC__", NULL);
tcc_define_symbol(s, "__STDC_VERSION__", "199901L");
#if defined(TCC_TARGET_I386) #if defined(TCC_TARGET_I386)
tcc_define_symbol(s, "__i386__", NULL); tcc_define_symbol(s, "__i386__", NULL);
#endif #endif