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
28typedef short int int16_t;28typedef short int int16_t;
29typedef int int32_t;29typedef int int32_t;
30typedef long long int int64_t;30typedef long long int int64_t;
31#endif
32
33typedef unsigned char uint8_t;31typedef unsigned char uint8_t;
34typedef unsigned short int uint16_t;32typedef unsigned short int uint16_t;
35typedef unsigned int uint32_t;33typedef unsigned int uint32_t;
36typedef unsigned long long int uint64_t;34typedef unsigned long long int uint64_t;
37#endif35#endif
36#endif
38 37
39/* Standard ELF types. */38/* Standard ELF types. */
40 39
tccgen.c+6−5
@@ -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 != '{'))
tests/tcctest.c+2−0
@@ -2303,7 +2303,9 @@ void c99_vla_test(int size1, int size2) · 2302 unmodified lines
2303#endif2303#endif
2304}2304}
2305 2305
2306#ifndef __TINYC__
2306typedef __SIZE_TYPE__ uintptr_t;2307typedef __SIZE_TYPE__ uintptr_t;
2308#endif
2307 2309
2308void sizeof_test(void)2310void sizeof_test(void)
2309{2311{
win32/include/_mingw.h+7−4
@@ -100,16 +100,19 @@ typedef __time64_t time_t; · 99 unmodified lines
100#define _TIME_T_DEFINED100#define _TIME_T_DEFINED
101#endif101#endif
102 102
103#if 0 // defined in stddef.h
103typedef unsigned long size_t;104typedef unsigned long size_t;
104#define _SIZE_T_DEFINED
105typedef long ssize_t;105typedef long ssize_t;
106typedef unsigned short wchar_t;
107#endif
108#define _SIZE_T_DEFINED
106#define _SSIZE_T_DEFINED109#define _SSIZE_T_DEFINED
110#define _WCHAR_T_DEFINED
107 111
108typedef unsigned int wint_t;
109typedef unsigned short wctype_t;112typedef unsigned short wctype_t;
113typedef unsigned int wint_t;
110#define _WCTYPE_T_DEFINED114#define _WCTYPE_T_DEFINED
111typedef unsigned short wchar_t;115#define _WINT_T
112#define _WCHAR_T_DEFINED
113 116
114typedef int errno_t;117typedef int errno_t;
115#define _ERRCODE_DEFINED118#define _ERRCODE_DEFINED
win32/include/stdint.h+3−0
@@ -31,6 +31,8 @@ · 30 unmodified lines
31#define __need_wchar_t31#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 */
35typedef signed char int8_t;37typedef signed char int8_t;
36typedef unsigned char uint8_t;38typedef unsigned char uint8_t;
@@ -40,6 +42,7 @@ typedef int int32_t; · 3 unmodified lines
40typedef unsigned uint32_t;42typedef unsigned uint32_t;
41typedef long long int64_t;43typedef long long int64_t;
42typedef unsigned long long uint64_t;44typedef 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 */
45typedef signed char int_least8_t;48typedef 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