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.
This commit is contained in:
3
elf.h
3
elf.h
@ -28,13 +28,12 @@ typedef signed char int8_t;
|
|||||||
typedef short int int16_t;
|
typedef short int int16_t;
|
||||||
typedef int int32_t;
|
typedef int int32_t;
|
||||||
typedef long long int int64_t;
|
typedef long long int int64_t;
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
typedef unsigned short int uint16_t;
|
typedef unsigned short int uint16_t;
|
||||||
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
typedef unsigned long long int uint64_t;
|
typedef unsigned long long int uint64_t;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Standard ELF types. */
|
/* Standard ELF types. */
|
||||||
|
|
||||||
|
|||||||
7
tccgen.c
7
tccgen.c
@ -239,11 +239,10 @@ ST_FUNC Sym *sym_push(int v, CType *type, int r, int c)
|
|||||||
ps = &ts->sym_identifier;
|
ps = &ts->sym_identifier;
|
||||||
s->prev_tok = *ps;
|
s->prev_tok = *ps;
|
||||||
*ps = s;
|
*ps = s;
|
||||||
if (local_scope) {
|
|
||||||
s->scope = local_scope;
|
s->scope = local_scope;
|
||||||
if (s->prev_tok && s->prev_tok->scope == s->scope)
|
if (s->prev_tok && s->prev_tok->scope == s->scope)
|
||||||
tcc_error("redeclaration of '%s'", get_tok_str(v & ~SYM_STRUCT, NULL));
|
tcc_error("redeclaration of '%s'",
|
||||||
}
|
get_tok_str(v & ~SYM_STRUCT, NULL));
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -2929,6 +2928,8 @@ static void struct_decl(CType *type, AttributeDef *ad, int u)
|
|||||||
expect("struct/union/enum name");
|
expect("struct/union/enum name");
|
||||||
s = struct_find(v);
|
s = struct_find(v);
|
||||||
if (s && s->type.t == a) {
|
if (s && s->type.t == a) {
|
||||||
|
if (0 == local_scope)
|
||||||
|
goto do_decl; /* compatibility with past behavior */
|
||||||
if (tok != '{' && tok != ';')
|
if (tok != '{' && tok != ';')
|
||||||
goto do_decl; /* variable declaration: 'struct s x;' */
|
goto do_decl; /* variable declaration: 'struct s x;' */
|
||||||
if (s->scope == local_scope && (s->c == -1 || tok != '{'))
|
if (s->scope == local_scope && (s->c == -1 || tok != '{'))
|
||||||
|
|||||||
@ -2303,7 +2303,9 @@ void c99_vla_test(int size1, int size2)
|
|||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef __TINYC__
|
||||||
typedef __SIZE_TYPE__ uintptr_t;
|
typedef __SIZE_TYPE__ uintptr_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -100,17 +100,20 @@ typedef __time64_t time_t;
|
|||||||
#define _TIME_T_DEFINED
|
#define _TIME_T_DEFINED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 0 // defined in stddef.h
|
||||||
typedef unsigned long size_t;
|
typedef unsigned long size_t;
|
||||||
#define _SIZE_T_DEFINED
|
|
||||||
typedef long ssize_t;
|
typedef long ssize_t;
|
||||||
#define _SSIZE_T_DEFINED
|
|
||||||
|
|
||||||
typedef unsigned int wint_t;
|
|
||||||
typedef unsigned short wctype_t;
|
|
||||||
#define _WCTYPE_T_DEFINED
|
|
||||||
typedef unsigned short wchar_t;
|
typedef unsigned short wchar_t;
|
||||||
|
#endif
|
||||||
|
#define _SIZE_T_DEFINED
|
||||||
|
#define _SSIZE_T_DEFINED
|
||||||
#define _WCHAR_T_DEFINED
|
#define _WCHAR_T_DEFINED
|
||||||
|
|
||||||
|
typedef unsigned short wctype_t;
|
||||||
|
typedef unsigned int wint_t;
|
||||||
|
#define _WCTYPE_T_DEFINED
|
||||||
|
#define _WINT_T
|
||||||
|
|
||||||
typedef int errno_t;
|
typedef int errno_t;
|
||||||
#define _ERRCODE_DEFINED
|
#define _ERRCODE_DEFINED
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,8 @@
|
|||||||
#define __need_wchar_t
|
#define __need_wchar_t
|
||||||
#include "stddef.h"
|
#include "stddef.h"
|
||||||
|
|
||||||
|
#ifndef __int8_t_defined
|
||||||
|
#define __int8_t_defined
|
||||||
/* 7.18.1.1 Exact-width integer types */
|
/* 7.18.1.1 Exact-width integer types */
|
||||||
typedef signed char int8_t;
|
typedef signed char int8_t;
|
||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
@ -40,6 +42,7 @@ typedef int int32_t;
|
|||||||
typedef unsigned uint32_t;
|
typedef unsigned uint32_t;
|
||||||
typedef long long int64_t;
|
typedef long long int64_t;
|
||||||
typedef unsigned long long uint64_t;
|
typedef unsigned long long uint64_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* 7.18.1.2 Minimum-width integer types */
|
/* 7.18.1.2 Minimum-width integer types */
|
||||||
typedef signed char int_least8_t;
|
typedef signed char int_least8_t;
|
||||||
|
|||||||
Reference in New Issue
Block a user