Allow const expr in builtin_frame_address/builtin_return_address

This commit is contained in:
herman ten brugge 2023-01-16 08:37:47 +01:00
parent 560526a49d
commit 79d439ee4f
2 changed files with 3 additions and 10 deletions

View File

@ -5601,17 +5601,16 @@ ST_FUNC void unary(void)
case TOK_builtin_return_address: case TOK_builtin_return_address:
{ {
int tok1 = tok; int tok1 = tok;
int level; int64_t level;
next(); next();
skip('('); skip('(');
if (tok != TOK_CINT) { level = expr_const64();
if (level < 0) {
tcc_error("%s only takes positive integers", tcc_error("%s only takes positive integers",
tok1 == TOK_builtin_return_address ? tok1 == TOK_builtin_return_address ?
"__builtin_return_address" : "__builtin_return_address" :
"__builtin_frame_address"); "__builtin_frame_address");
} }
level = (uint32_t)tokc.i;
next();
skip(')'); skip(')');
type.t = VT_VOID; type.t = VT_VOID;
mk_pointer(&type); mk_pointer(&type);

View File

@ -25,12 +25,6 @@ int compile_errors(void)
l1: return 1; l1: return 1;
l2: return 2; l2: return 2;
} }
#endif
#if TEST == 4
{
/* Only integer allowed */
__builtin_return_address(0 + 1) != NULL;
}
#endif #endif
return 0; return 0;
} }