diff options
author | David Malcolm <dmalcolm@redhat.com> | 2015-07-07 19:29:58 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2015-07-07 19:29:58 +0000 |
commit | 3457d39ea5c16b07c5e1a1d4691b1db27f1e5223 (patch) | |
tree | 4e27cf9de6ad3f9acd2c9a0c0386dbab0e1f4e2e /gcc/jit/libgccjit.c | |
parent | bada4bed71933a5170b41585b6fb52a45eaf5e8a (diff) | |
download | gcc-3457d39ea5c16b07c5e1a1d4691b1db27f1e5223.zip gcc-3457d39ea5c16b07c5e1a1d4691b1db27f1e5223.tar.gz gcc-3457d39ea5c16b07c5e1a1d4691b1db27f1e5223.tar.bz2 |
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".
From-SVN: r225523
Diffstat (limited to 'gcc/jit/libgccjit.c')
-rw-r--r-- | gcc/jit/libgccjit.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index 4d7dd8c..85d9f62 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); } |