fix __builtin_expect

the second argument can be an arbitrary expression (including
side-effects), not just a constant.  This removes the last user
of expr_lor_const and hence also that function (and expr_land_const).
Also the argument to __builtin_constant_p can be only a non-comma
expression (like all functions arguments).
This commit is contained in:
Michael Matz 2017-01-17 00:06:44 +01:00
parent 8d9dd3c008
commit 3c39cb5cd8

View File

@ -81,7 +81,6 @@ 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 expr_lor_const(void);
static void unary_type(CType *type);
static void vla_runtime_type_size(CType *type, int *a);
static void vla_sp_restore(void);
@ -4512,10 +4511,8 @@ ST_FUNC void unary(void)
skip('(');
expr_eq();
skip(',');
nocode_wanted++;
expr_lor_const();
expr_eq();
vpop();
nocode_wanted--;
skip(')');
}
break;
@ -4566,7 +4563,7 @@ ST_FUNC void unary(void)
next();
skip('(');
nocode_wanted++;
gexpr();
expr_eq();
res = (vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
vpop();
nocode_wanted--;
@ -5056,26 +5053,6 @@ static void expr_or(void)
}
}
/* XXX: fix this mess */
static void expr_land_const(void)
{
expr_or();
while (tok == TOK_LAND) {
next();
expr_or();
gen_op(TOK_LAND);
}
}
static void expr_lor_const(void)
{
expr_land_const();
while (tok == TOK_LOR) {
next();
expr_land_const();
gen_op(TOK_LOR);
}
}
static void expr_land(void)
{
expr_or();