aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorPavlas, Zdenek <zden3k@gmail.com>2016-11-09 04:03:17 -0800
committerPavlas, Zdenek <zden3k@gmail.com>2016-11-09 04:11:40 -0800
commit550e861bf7a2196cec7d7844526c3f11e810c5be (patch)
tree61ece60167adf70cc423009bb4e1f4fe1a958b3d /tccgen.c
parentcdf715a0b5bf26f6e19dfd75fdbf23deffcc6d1c (diff)
downloadtinycc-550e861bf7a2196cec7d7844526c3f11e810c5be.tar.gz
tinycc-550e861bf7a2196cec7d7844526c3f11e810c5be.tar.bz2
bcheck: add structs to local regions
int test() { struct { int i; } s = { 42 }; return s.i; // bound checked }
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tccgen.c b/tccgen.c
index fdd8654..a8e1e97 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -6234,7 +6234,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
if ((r & VT_VALMASK) == VT_LOCAL) {
sec = NULL;
#ifdef CONFIG_TCC_BCHECK
- if (tcc_state->do_bounds_check && (type->t & VT_ARRAY)) {
+ if (tcc_state->do_bounds_check && ((type->t & VT_ARRAY) || (type->t & VT_BTYPE) == VT_STRUCT)) {
loc--;
}
#endif
@@ -6244,7 +6244,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
/* handles bounds */
/* XXX: currently, since we do only one pass, we cannot track
'&' operators, so we add only arrays */
- if (tcc_state->do_bounds_check && (type->t & VT_ARRAY)) {
+ if (tcc_state->do_bounds_check && ((type->t & VT_ARRAY) || (type->t & VT_BTYPE) == VT_STRUCT)) {
addr_t *bounds_ptr;
/* add padding between regions */
loc--;