diff options
author | David Malcolm <dmalcolm@redhat.com> | 2015-06-17 16:04:18 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2015-06-17 16:04:18 +0000 |
commit | 41571b55b1c023158fda594eafa431e943c87819 (patch) | |
tree | 10a4226e3f1ed7c7916021c9e43f14c899f827d4 /gcc/jit/libgccjit.c | |
parent | ee47f74ef0e961a0168e830919606981ef331c52 (diff) | |
download | gcc-41571b55b1c023158fda594eafa431e943c87819.zip gcc-41571b55b1c023158fda594eafa431e943c87819.tar.gz gcc-41571b55b1c023158fda594eafa431e943c87819.tar.bz2 |
jit: Add missing type-checking to gcc_jit_{l|r}value_access_field
gcc/jit/ChangeLog:
* libgccjit.c (gcc_jit_lvalue_access_field): Verify that the field
is for the correct struct.
(gcc_jit_rvalue_access_field): Likewise.
gcc/testsuite/ChangeLog:
* jit.dg/test-error-accessing-field-in-other-struct.c: Rename to...
* jit.dg/test-error-gcc_jit_rvalue_dereference_field-wrong-struct.c:
...this.
* jit.dg/test-error-gcc_jit_lvalue_access_field-wrong-struct.c:
New testcase.
* jit.dg/test-error-gcc_jit_rvalue_access_field-wrong-struct.c:
New testcase.
From-SVN: r224565
Diffstat (limited to 'gcc/jit/libgccjit.c')
-rw-r--r-- | gcc/jit/libgccjit.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index 7eb66bd..dedf942 100644 --- a/gcc/jit/libgccjit.c +++ b/gcc/jit/libgccjit.c @@ -1671,6 +1671,15 @@ gcc_jit_lvalue_access_field (gcc_jit_lvalue *struct_, RETURN_NULL_IF_FAIL_PRINTF1 (field->get_container (), field->m_ctxt, loc, "field %s has not been placed in a struct", field->get_debug_string ()); + gcc::jit::recording::type *underlying_type = + struct_->get_type (); + RETURN_NULL_IF_FAIL_PRINTF2 ( + (field->get_container ()->unqualified () + == underlying_type->unqualified ()), + struct_->m_ctxt, loc, + "%s is not a field of %s", + field->get_debug_string (), + underlying_type->get_debug_string ()); return (gcc_jit_lvalue *)struct_->access_field (loc, field); } @@ -1694,6 +1703,15 @@ gcc_jit_rvalue_access_field (gcc_jit_rvalue *struct_, RETURN_NULL_IF_FAIL_PRINTF1 (field->get_container (), field->m_ctxt, loc, "field %s has not been placed in a struct", field->get_debug_string ()); + gcc::jit::recording::type *underlying_type = + struct_->get_type (); + RETURN_NULL_IF_FAIL_PRINTF2 ( + (field->get_container ()->unqualified () + == underlying_type->unqualified ()), + struct_->m_ctxt, loc, + "%s is not a field of %s", + field->get_debug_string (), + underlying_type->get_debug_string ()); return (gcc_jit_rvalue *)struct_->access_field (loc, field); } |