History

Tidy typename parsing a bit

Michael Matz committed 9 years ago

Commit 5891fbc1 parent 51314931 file · +16 −26Browse files

Unified · Split

tccgen.c+16−26
@@ -81,12 +81,10 @@ static void block(int *bsym, int *csym, int is_expr); · 80 unmodified lines
8181 static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, int has_init, int v, int scope);
8282 static int decl0(int l, int is_for_loop_init);
8383 static void expr_eq(void);
84−static void unary_type(CType *type);
8584 static void vla_runtime_type_size(CType *type, int *a);
8685 static void vla_sp_restore(void);
8786 static void vla_sp_restore_root(void);
8887 static int is_compatible_parameter_types(CType *type1, CType *type2);
89−static void expr_type(CType *type);
9088 static inline int64_t expr_const64(void);
9189 ST_FUNC void vpush64(int ty, unsigned long long v);
9290 ST_FUNC void vpush(CType *type);
@@ -4255,6 +4253,20 @@ static void gfunc_param_typed(Sym *func, Sym *arg) · 4162 unmodified lines
42554253 }
42564254 }
42574255
4256+/* parse an expression and return its type without any side effect.
4257+ If UNRY we parse an unary expression, otherwise a full one. */
4258+static void expr_type(CType *type, int unry)
4259+{
4260+ nocode_wanted++;
4261+ if (unry)
4262+ unary();
4263+ else
4264+ gexpr();
4265+ *type = vtop->type;
4266+ vpop();
4267+ nocode_wanted--;
4268+}
4269+
42584270 /* parse an expression of the form '(type)' or '(expr)' and return its
42594271 type */
42604272 static void parse_expr_type(CType *type)
@@ -4266,7 +4278,7 @@ static void parse_expr_type(CType *type) · 5 unmodified lines
42664278 if (parse_btype(type, &ad)) {
42674279 type_decl(type, &ad, &n, TYPE_ABSTRACT);
42684280 } else {
4269− expr_type(type);
4281+ expr_type(type, 0);
42704282 }
42714283 skip(')');
42724284 }
@@ -4501,7 +4513,7 @@ ST_FUNC void unary(void) · 228 unmodified lines
45014513 t = tok;
45024514 next();
45034515 in_sizeof++;
4504− unary_type(&type); // Perform a in_sizeof = 0;
4516+ expr_type(&type, 1); // Perform a in_sizeof = 0;
45054517 size = type_size(&type, &align);
45064518 if (t == TOK_SIZEOF) {
45074519 if (!(type.t & VT_VLA)) {
@@ -5329,28 +5341,6 @@ ST_FUNC void gexpr(void) · 821 unmodified lines
53295341 }
53305342 }
53315343
5332−/* parse an expression and return its type without any side effect. */
5333−static void expr_type(CType *type)
5334−{
5335−
5336− nocode_wanted++;
5337− gexpr();
5338− *type = vtop->type;
5339− vpop();
5340− nocode_wanted--;
5341−}
5342−
5343−/* parse a unary expression and return its type without any side
5344− effect. */
5345−static void unary_type(CType *type)
5346−{
5347− nocode_wanted++;
5348− unary();
5349− *type = vtop->type;
5350− vpop();
5351− nocode_wanted--;
5352−}
5353−
53545344 /* parse a constant expression and return value in vtop. */
53555345 static void expr_const1(void)
53565346 {