From 8ca98e23c4e54b1552c819425890584e6357f46a Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Mon, 6 Mar 2017 21:45:41 +0100 Subject: Tidy unary() a bit factor code a bit for transforming tokens into SValues. This revealed a bug in TOK_GET (see testcase), which happened to be harmless before. So fix that as well. --- tccgen.c | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) (limited to 'tccgen.c') diff --git a/tccgen.c b/tccgen.c index e3ba5cc..2f93796 100644 --- a/tccgen.c +++ b/tccgen.c @@ -4297,14 +4297,6 @@ static void parse_type(CType *type) type_decl(type, &ad, &n, TYPE_ABSTRACT); } -static void vpush_tokc(int t) -{ - CType type; - type.t = t; - type.ref = 0; - vsetc(&type, VT_CONST, &tokc); -} - static void parse_builtin_params(int nc, const char *args) { char c, sep = '('; @@ -4345,33 +4337,32 @@ ST_FUNC void unary(void) case TOK_CINT: case TOK_CCHAR: case TOK_LCHAR: - vpushi(tokc.i); + t = VT_INT; + push_tokc: + type.t = t; + type.ref = 0; + vsetc(&type, VT_CONST, &tokc); next(); break; case TOK_CUINT: - vpush_tokc(VT_INT | VT_UNSIGNED); - next(); - break; + t = VT_INT | VT_UNSIGNED; + goto push_tokc; case TOK_CLLONG: - vpush_tokc(VT_LLONG); - next(); - break; + t = VT_LLONG; + goto push_tokc; case TOK_CULLONG: - vpush_tokc(VT_LLONG | VT_UNSIGNED); - next(); - break; + t =VT_LLONG | VT_UNSIGNED; + goto push_tokc; case TOK_CFLOAT: - vpush_tokc(VT_FLOAT); - next(); - break; + t = VT_FLOAT; + goto push_tokc; case TOK_CDOUBLE: - vpush_tokc(VT_DOUBLE); - next(); - break; + t = VT_DOUBLE; + goto push_tokc; case TOK_CLDOUBLE: - vpush_tokc(VT_LDOUBLE); - next(); - break; + t = VT_LDOUBLE; + goto push_tokc; + case TOK___FUNCTION__: if (!gnu_ext) goto tok_identifier; -- cgit v1.3.1