diff options
author | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-06-17 16:04:18 +0000 |
---|---|---|
committer | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-06-17 16:04:18 +0000 |
commit | 6689f47f53079d76bbb051d3b5da9018c2e0161a (patch) | |
tree | 10a4226e3f1ed7c7916021c9e43f14c899f827d4 /gcc/jit | |
parent | 29e65f8eb22a557b8d6cf926c260a1e2a17bf1e4 (diff) | |
download | gcc-6689f47f53079d76bbb051d3b5da9018c2e0161a.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224565 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/jit')
-rw-r--r-- | gcc/jit/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/jit/libgccjit.c | 18 |
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index d9e61b657a3..a131171a342 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,3 +1,9 @@ +2015-06-17 David Malcolm <dmalcolm@redhat.com> + + * libgccjit.c (gcc_jit_lvalue_access_field): Verify that the field + is for the correct struct. + (gcc_jit_rvalue_access_field): Likewise. + 2015-06-17 Andrew MacLeod <amacleod@redhat.com> * dummy-frontend.c: Do not include input.h, line-map.h or is-a.h. diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index 7eb66bdae50..dedf942ebaa 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); } |