History

tccgen: scopes levels for local symbols (update 1)

Catch top level redeclarations too. Also fix mistakes in tcctest.c and the tcc sources (win32) showing up now.

grischka committed 10 years ago

Commit d48662d1 parent fe845cf5 files · +19 −11Browse files

Unified · Split

5 files
  1. elf.h +1 −2
  2. tccgen.c +6 −5
  3. tests/tcctest.c +2 −0
  4. win32/include/_mingw.h +7 −4
  5. win32/include/stdint.h +3 −0
elf.h+1−2
@@ -28,13 +28,12 @@ typedef signed char int8_t; · 27 unmodified lines
2828 typedef short int int16_t;
2929 typedef int int32_t;
3030 typedef long long int int64_t;
31−#endif
32−
3331 typedef unsigned char uint8_t;
3432 typedef unsigned short int uint16_t;
3533 typedef unsigned int uint32_t;
3634 typedef unsigned long long int uint64_t;
3735 #endif
36+#endif
3837
3938 /* Standard ELF types. */
4039
tccgen.c+6−5
@@ -239,11 +239,10 @@ ST_FUNC Sym *sym_push(int v, CType *type, int r, int c) · 238 unmodified lines
239239 ps = &ts->sym_identifier;
240240 s->prev_tok = *ps;
241241 *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));
247246 }
248247 return s;
249248 }
@@ -2929,6 +2928,8 @@ static void struct_decl(CType *type, AttributeDef *ad, int u) · 2679 unmodified lines
29292928 expect("struct/union/enum name");
29302929 s = struct_find(v);
29312930 if (s && s->type.t == a) {
2931+ if (0 == local_scope)
2932+ goto do_decl; /* compatibility with past behavior */
29322933 if (tok != '{' && tok != ';')
29332934 goto do_decl; /* variable declaration: 'struct s x;' */
29342935 if (s->scope == local_scope && (s->c == -1 || tok != '{'))
tests/tcctest.c+2−0
@@ -2303,7 +2303,9 @@ void c99_vla_test(int size1, int size2) · 2302 unmodified lines
23032303 #endif
23042304 }
23052305
2306+#ifndef __TINYC__
23062307 typedef __SIZE_TYPE__ uintptr_t;
2308+#endif
23072309
23082310 void sizeof_test(void)
23092311 {
win32/include/_mingw.h+7−4
@@ -100,16 +100,19 @@ typedef __time64_t time_t; · 99 unmodified lines
100100 #define _TIME_T_DEFINED
101101 #endif
102102
103+#if 0 // defined in stddef.h
103104 typedef unsigned long size_t;
104−#define _SIZE_T_DEFINED
105105 typedef long ssize_t;
106+typedef unsigned short wchar_t;
107+#endif
108+#define _SIZE_T_DEFINED
106109 #define _SSIZE_T_DEFINED
110+#define _WCHAR_T_DEFINED
107111
108−typedef unsigned int wint_t;
109112 typedef unsigned short wctype_t;
113+typedef unsigned int wint_t;
110114 #define _WCTYPE_T_DEFINED
111−typedef unsigned short wchar_t;
112−#define _WCHAR_T_DEFINED
115+#define _WINT_T
113116
114117 typedef int errno_t;
115118 #define _ERRCODE_DEFINED
win32/include/stdint.h+3−0
@@ -31,6 +31,8 @@ · 30 unmodified lines
3131 #define __need_wchar_t
3232 #include "stddef.h"
3333
34+#ifndef __int8_t_defined
35+#define __int8_t_defined
3436 /* 7.18.1.1 Exact-width integer types */
3537 typedef signed char int8_t;
3638 typedef unsigned char uint8_t;
@@ -40,6 +42,7 @@ typedef int int32_t; · 3 unmodified lines
4042 typedef unsigned uint32_t;
4143 typedef long long int64_t;
4244 typedef unsigned long long uint64_t;
45+#endif
4346
4447 /* 7.18.1.2 Minimum-width integer types */
4548 typedef signed char int_least8_t;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t