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
5601 case TOK_builtin_return_address:5601 case TOK_builtin_return_address:
5602 {5602 {
5603 int tok1 = tok;5603 int tok1 = tok;
5604 int level;5604 int64_t level;
5605 next();5605 next();
5606 skip('(');5606 skip('(');
5607 if (tok != TOK_CINT) {5607 level = expr_const64();
5608 if (level < 0) {
5608 tcc_error("%s only takes positive integers",5609 tcc_error("%s only takes positive integers",
5609 tok1 == TOK_builtin_return_address ?5610 tok1 == TOK_builtin_return_address ?
5610 "__builtin_return_address" :5611 "__builtin_return_address" :
5611 "__builtin_frame_address");5612 "__builtin_frame_address");
5612 }5613 }
5613 level = (uint32_t)tokc.i;
5614 next();
5615 skip(')');5614 skip(')');
5616 type.t = VT_VOID;5615 type.t = VT_VOID;
5617 mk_pointer(&type);5616 mk_pointer(&type);
tests/bug.c+0−6
@@ -25,12 +25,6 @@ int compile_errors(void) · 24 unmodified lines
25 l1: return 1;25 l1: return 1;
26 l2: return 2;26 l2: return 2;
27 }27 }
28#endif
29#if TEST == 4
30 {
31 /* Only integer allowed */
32 __builtin_return_address(0 + 1) != NULL;
33 }
34#endif28#endif
35 return 0;29 return 0;
36}30}

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