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