History

bcheck: add structs to local regions

int test() { struct { int i; } s = { 42 }; return s.i; // bound checked }

Pavlas, Zdenek committed 10 years ago

Commit 550e8611 parent cdf715a1 file · +2 −2Browse files

Unified · Split

tccgen.c+2−2
@@ -6234,7 +6234,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 6233 unmodified lines
6234 if ((r & VT_VALMASK) == VT_LOCAL) {6234 if ((r & VT_VALMASK) == VT_LOCAL) {
6235 sec = NULL;6235 sec = NULL;
6236#ifdef CONFIG_TCC_BCHECK6236#ifdef CONFIG_TCC_BCHECK
6237 if (tcc_state->do_bounds_check && (type->t & VT_ARRAY)) {6237 if (tcc_state->do_bounds_check && ((type->t & VT_ARRAY) || (type->t & VT_BTYPE) == VT_STRUCT)) {
6238 loc--;6238 loc--;
6239 }6239 }
6240#endif6240#endif
@@ -6244,7 +6244,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 3 unmodified lines
6244 /* handles bounds */6244 /* handles bounds */
6245 /* XXX: currently, since we do only one pass, we cannot track6245 /* XXX: currently, since we do only one pass, we cannot track
6246 '&' operators, so we add only arrays */6246 '&' operators, so we add only arrays */
6247 if (tcc_state->do_bounds_check && (type->t & VT_ARRAY)) {6247 if (tcc_state->do_bounds_check && ((type->t & VT_ARRAY) || (type->t & VT_BTYPE) == VT_STRUCT)) {
6248 addr_t *bounds_ptr;6248 addr_t *bounds_ptr;
6249 /* add padding between regions */6249 /* add padding between regions */
6250 loc--;6250 loc--;

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