diff options
| author | Michael Matz <matz@suse.de> | 2017-02-27 03:34:33 +0100 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2017-05-02 03:07:36 +0200 |
| commit | 5891fbc0c8ff00a07fd323fa34760348b772f87e (patch) | |
| tree | c7d9c7a1a170a312567dc70d542229fc8f5dfccf | |
| parent | 51314932e31fc077341fb5991ebe58f41ecea488 (diff) | |
| download | tinycc-5891fbc0c8ff00a07fd323fa34760348b772f87e.tar.gz tinycc-5891fbc0c8ff00a07fd323fa34760348b772f87e.tar.bz2 | |
Tidy typename parsing a bit
| -rw-r--r-- | tccgen.c | 42 |
1 files changed, 16 insertions, 26 deletions
@@ -81,12 +81,10 @@ static void block(int *bsym, int *csym, int is_expr); static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, int has_init, int v, int scope); static int decl0(int l, int is_for_loop_init); static void expr_eq(void); -static void unary_type(CType *type); static void vla_runtime_type_size(CType *type, int *a); static void vla_sp_restore(void); static void vla_sp_restore_root(void); static int is_compatible_parameter_types(CType *type1, CType *type2); -static void expr_type(CType *type); static inline int64_t expr_const64(void); ST_FUNC void vpush64(int ty, unsigned long long v); ST_FUNC void vpush(CType *type); @@ -4255,6 +4253,20 @@ static void gfunc_param_typed(Sym *func, Sym *arg) } } +/* parse an expression and return its type without any side effect. + If UNRY we parse an unary expression, otherwise a full one. */ +static void expr_type(CType *type, int unry) +{ + nocode_wanted++; + if (unry) + unary(); + else + gexpr(); + *type = vtop->type; + vpop(); + nocode_wanted--; +} + /* parse an expression of the form '(type)' or '(expr)' and return its type */ static void parse_expr_type(CType *type) @@ -4266,7 +4278,7 @@ static void parse_expr_type(CType *type) if (parse_btype(type, &ad)) { type_decl(type, &ad, &n, TYPE_ABSTRACT); } else { - expr_type(type); + expr_type(type, 0); } skip(')'); } @@ -4501,7 +4513,7 @@ ST_FUNC void unary(void) t = tok; next(); in_sizeof++; - unary_type(&type); // Perform a in_sizeof = 0; + expr_type(&type, 1); // Perform a in_sizeof = 0; size = type_size(&type, &align); if (t == TOK_SIZEOF) { if (!(type.t & VT_VLA)) { @@ -5329,28 +5341,6 @@ ST_FUNC void gexpr(void) } } -/* parse an expression and return its type without any side effect. */ -static void expr_type(CType *type) -{ - - nocode_wanted++; - gexpr(); - *type = vtop->type; - vpop(); - nocode_wanted--; -} - -/* parse a unary expression and return its type without any side - effect. */ -static void unary_type(CType *type) -{ - nocode_wanted++; - unary(); - *type = vtop->type; - vpop(); - nocode_wanted--; -} - /* parse a constant expression and return value in vtop. */ static void expr_const1(void) { |
