Catch top level redeclarations too. Also fix mistakes in tcctest.c and the tcc sources (win32) showing up now.
Unified · Split
| @@ -28,13 +28,12 @@ typedef signed char int8_t; · 27 unmodified lines | ||
| 28 | 28 | typedef short int int16_t; |
| 29 | 29 | typedef int int32_t; |
| 30 | 30 | typedef long long int int64_t; |
| 31 | −#endif | |
| 32 | − | |
| 33 | 31 | typedef unsigned char uint8_t; |
| 34 | 32 | typedef unsigned short int uint16_t; |
| 35 | 33 | typedef unsigned int uint32_t; |
| 36 | 34 | typedef unsigned long long int uint64_t; |
| 37 | 35 | #endif |
| 36 | +#endif | |
| 38 | 37 | |
| 39 | 38 | /* Standard ELF types. */ |
| 40 | 39 | |
| @@ -239,11 +239,10 @@ ST_FUNC Sym *sym_push(int v, CType *type, int r, int c) · 238 unmodified lines | ||
| 239 | 239 | ps = &ts->sym_identifier; |
| 240 | 240 | s->prev_tok = *ps; |
| 241 | 241 | *ps = s; |
| 242 | − if (local_scope) { | |
| 243 | − s->scope = local_scope; | |
| 244 | − if (s->prev_tok && s->prev_tok->scope == s->scope) | |
| 245 | − tcc_error("redeclaration of '%s'", get_tok_str(v & ~SYM_STRUCT, NULL)); | |
| 246 | − } | |
| 242 | + s->scope = local_scope; | |
| 243 | + if (s->prev_tok && s->prev_tok->scope == s->scope) | |
| 244 | + tcc_error("redeclaration of '%s'", | |
| 245 | + get_tok_str(v & ~SYM_STRUCT, NULL)); | |
| 247 | 246 | } |
| 248 | 247 | return s; |
| 249 | 248 | } |
| @@ -2929,6 +2928,8 @@ static void struct_decl(CType *type, AttributeDef *ad, int u) · 2679 unmodified lines | ||
| 2929 | 2928 | expect("struct/union/enum name"); |
| 2930 | 2929 | s = struct_find(v); |
| 2931 | 2930 | if (s && s->type.t == a) { |
| 2931 | + if (0 == local_scope) | |
| 2932 | + goto do_decl; /* compatibility with past behavior */ | |
| 2932 | 2933 | if (tok != '{' && tok != ';') |
| 2933 | 2934 | goto do_decl; /* variable declaration: 'struct s x;' */ |
| 2934 | 2935 | if (s->scope == local_scope && (s->c == -1 || tok != '{')) |
| @@ -2303,7 +2303,9 @@ void c99_vla_test(int size1, int size2) · 2302 unmodified lines | ||
| 2303 | 2303 | #endif |
| 2304 | 2304 | } |
| 2305 | 2305 | |
| 2306 | +#ifndef __TINYC__ | |
| 2306 | 2307 | typedef __SIZE_TYPE__ uintptr_t; |
| 2308 | +#endif | |
| 2307 | 2309 | |
| 2308 | 2310 | void sizeof_test(void) |
| 2309 | 2311 | { |
| @@ -100,16 +100,19 @@ typedef __time64_t time_t; · 99 unmodified lines | ||
| 100 | 100 | #define _TIME_T_DEFINED |
| 101 | 101 | #endif |
| 102 | 102 | |
| 103 | +#if 0 // defined in stddef.h | |
| 103 | 104 | typedef unsigned long size_t; |
| 104 | −#define _SIZE_T_DEFINED | |
| 105 | 105 | typedef long ssize_t; |
| 106 | +typedef unsigned short wchar_t; | |
| 107 | +#endif | |
| 108 | +#define _SIZE_T_DEFINED | |
| 106 | 109 | #define _SSIZE_T_DEFINED |
| 110 | +#define _WCHAR_T_DEFINED | |
| 107 | 111 | |
| 108 | −typedef unsigned int wint_t; | |
| 109 | 112 | typedef unsigned short wctype_t; |
| 113 | +typedef unsigned int wint_t; | |
| 110 | 114 | #define _WCTYPE_T_DEFINED |
| 111 | −typedef unsigned short wchar_t; | |
| 112 | −#define _WCHAR_T_DEFINED | |
| 115 | +#define _WINT_T | |
| 113 | 116 | |
| 114 | 117 | typedef int errno_t; |
| 115 | 118 | #define _ERRCODE_DEFINED |
| @@ -31,6 +31,8 @@ · 30 unmodified lines | ||
| 31 | 31 | #define __need_wchar_t |
| 32 | 32 | #include "stddef.h" |
| 33 | 33 | |
| 34 | +#ifndef __int8_t_defined | |
| 35 | +#define __int8_t_defined | |
| 34 | 36 | /* 7.18.1.1 Exact-width integer types */ |
| 35 | 37 | typedef signed char int8_t; |
| 36 | 38 | typedef unsigned char uint8_t; |
| @@ -40,6 +42,7 @@ typedef int int32_t; · 3 unmodified lines | ||
| 40 | 42 | typedef unsigned uint32_t; |
| 41 | 43 | typedef long long int64_t; |
| 42 | 44 | typedef unsigned long long uint64_t; |
| 45 | +#endif | |
| 43 | 46 | |
| 44 | 47 | /* 7.18.1.2 Minimum-width integer types */ |
| 45 | 48 | typedef signed char int_least8_t; |