History

Allow const expr in builtin_frame_address/builtin_return_address

herman ten brugge committed 3 years ago

Commit 79d439e1 parent 560526a2 files · +3 −10Browse files

Unified · Split

2 files
  1. tccgen.c +3 −4
  2. tests/bug.c +0 −6
tccgen.c+3−4
@@ -5601,17 +5601,16 @@ ST_FUNC void unary(void) · 5600 unmodified lines
56015601 case TOK_builtin_return_address:
56025602 {
56035603 int tok1 = tok;
5604− int level;
5604+ int64_t level;
56055605 next();
56065606 skip('(');
5607− if (tok != TOK_CINT) {
5607+ level = expr_const64();
5608+ if (level < 0) {
56085609 tcc_error("%s only takes positive integers",
56095610 tok1 == TOK_builtin_return_address ?
56105611 "__builtin_return_address" :
56115612 "__builtin_frame_address");
56125613 }
5613− level = (uint32_t)tokc.i;
5614− next();
56155614 skip(')');
56165615 type.t = VT_VOID;
56175616 mk_pointer(&type);
tests/bug.c+0−6
@@ -25,12 +25,6 @@ int compile_errors(void) · 24 unmodified lines
2525 l1: return 1;
2626 l2: return 2;
2727 }
28−#endif
29−#if TEST == 4
30− {
31− /* Only integer allowed */
32− __builtin_return_address(0 + 1) != NULL;
33− }
3428 #endif
3529 return 0;
3630 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t