summaryrefslogtreecommitdiff
path: root/gcc/jit
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-07 19:29:58 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-07 19:29:58 +0000
commitd0278351a2f98b0b6b76531c342462a84d6d9c19 (patch)
tree4e27cf9de6ad3f9acd2c9a0c0386dbab0e1f4e2e /gcc/jit
parent9793d5a6489818bfcd667a216f148d90048f1940 (diff)
downloadgcc-d0278351a2f98b0b6b76531c342462a84d6d9c19.tar.gz
PR jit/66783: prevent use of opaque structs
gcc/jit/ChangeLog: PR jit/66783 * jit-recording.h: Within namespace gcc:jit::recording... (type::has_known_size): New virtual function. (struct_has_known_size): New function. * libgccjit.c (gcc_jit_context_new_field): Verify that the type has a known size. (gcc_jit_context_new_global): Likewise. (gcc_jit_function_new_local): Likewise. gcc/testsuite/ChangeLog: PR jit/66783 * jit.dg/test-error-gcc_jit_context_new_field-opaque-struct.c: New test case. * jit.dg/test-error-gcc_jit_context_new_global-opaque-struct.c: New test case. * jit.dg/test-error-gcc_jit_function_new_local-opaque-struct.c: New test case. * jit.dg/test-error-mismatching-types-in-call.c (create_code): Avoid using an opaque struct for local "f". git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225523 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/jit')
-rw-r--r--gcc/jit/ChangeLog11
-rw-r--r--gcc/jit/jit-recording.h3
-rw-r--r--gcc/jit/libgccjit.c15
3 files changed, 29 insertions, 0 deletions
diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog
index c38fd5092fa..dbead11e0e2 100644
--- a/gcc/jit/ChangeLog
+++ b/gcc/jit/ChangeLog
@@ -1,5 +1,16 @@
2015-07-07 David Malcolm <dmalcolm@redhat.com>
+ PR jit/66783
+ * jit-recording.h: Within namespace gcc:jit::recording...
+ (type::has_known_size): New virtual function.
+ (struct_has_known_size): New function.
+ * libgccjit.c (gcc_jit_context_new_field): Verify that the type
+ has a known size.
+ (gcc_jit_context_new_global): Likewise.
+ (gcc_jit_function_new_local): Likewise.
+
+2015-07-07 David Malcolm <dmalcolm@redhat.com>
+
PR jit/66779
* dummy-frontend.c (jit_langhook_type_for_mode): Ensure that we
handle modes QI, HI, SI, DI, TI.
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index acd69e9b78c..884304b0ff8 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -497,6 +497,7 @@ public:
virtual type *is_pointer () = 0;
virtual type *is_array () = 0;
virtual bool is_void () const { return false; }
+ virtual bool has_known_size () const { return true; }
bool is_numeric () const
{
@@ -795,6 +796,8 @@ public:
type *is_pointer () { return NULL; }
type *is_array () { return NULL; }
+ bool has_known_size () const { return m_fields != NULL; }
+
playback::compound_type *
playback_compound_type ()
{
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index 4d7dd8cf40f..85d9f62f041 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -543,6 +543,11 @@ gcc_jit_context_new_field (gcc_jit_context *ctxt,
/* LOC can be NULL. */
RETURN_NULL_IF_FAIL (type, ctxt, loc, "NULL type");
RETURN_NULL_IF_FAIL (name, ctxt, loc, "NULL name");
+ RETURN_NULL_IF_FAIL_PRINTF1 (
+ type->has_known_size (),
+ ctxt, loc,
+ "type has unknown size (type: %s)",
+ type->get_debug_string ());
return (gcc_jit_field *)ctxt->new_field (loc, type, name);
}
@@ -1033,6 +1038,11 @@ gcc_jit_context_new_global (gcc_jit_context *ctxt,
kind);
RETURN_NULL_IF_FAIL (type, ctxt, loc, "NULL type");
RETURN_NULL_IF_FAIL (name, ctxt, loc, "NULL name");
+ RETURN_NULL_IF_FAIL_PRINTF1 (
+ type->has_known_size (),
+ ctxt, loc,
+ "type has unknown size (type: %s)",
+ type->get_debug_string ());
return (gcc_jit_lvalue *)ctxt->new_global (loc, kind, type, name);
}
@@ -1829,6 +1839,11 @@ gcc_jit_function_new_local (gcc_jit_function *func,
"Cannot add locals to an imported function");
RETURN_NULL_IF_FAIL (type, ctxt, loc, "NULL type");
RETURN_NULL_IF_FAIL (name, ctxt, loc, "NULL name");
+ RETURN_NULL_IF_FAIL_PRINTF1 (
+ type->has_known_size (),
+ ctxt, loc,
+ "type has unknown size (type: %s)",
+ type->get_debug_string ());
return (gcc_jit_lvalue *)func->new_local (loc, type, name);
}