Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type checks in gcc_jit_block_add_assignment_op #34

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions gcc/jit/libgccjit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ struct gcc_jit_extended_asm : public gcc::jit::recording::extended_asm
} \
JIT_END_STMT

#define RETURN_IF_FAIL_PRINTF3(TEST_EXPR, CTXT, LOC, ERR_FMT, A0, A1, A2) \
JIT_BEGIN_STMT \
if (!(TEST_EXPR)) \
{ \
jit_error ((CTXT), (LOC), "%s: " ERR_FMT, \
__func__, (A0), (A1), (A2)); \
return; \
} \
JIT_END_STMT

#define RETURN_IF_FAIL_PRINTF4(TEST_EXPR, CTXT, LOC, ERR_FMT, A0, A1, A2, A3) \
JIT_BEGIN_STMT \
if (!(TEST_EXPR)) \
Expand Down Expand Up @@ -3076,6 +3086,16 @@ gcc_jit_block_add_assignment_op (gcc_jit_block *block,
lvalue->get_type ()->get_debug_string (),
rvalue->get_debug_string (),
rvalue->get_type ()->get_debug_string ());
RETURN_IF_FAIL_PRINTF3 (
lvalue->get_type ()->is_numeric () && rvalue->get_type ()->is_numeric (), ctxt, loc,
"gcc_jit_block_add_assignment_op %s has non-numeric lvalue %s (type: %s)",
gcc::jit::binary_op_reproducer_strings[op],
lvalue->get_debug_string (), lvalue->get_type ()->get_debug_string ());
RETURN_IF_FAIL_PRINTF3 (
rvalue->get_type ()->is_numeric () && rvalue->get_type ()->is_numeric (), ctxt, loc,
"gcc_jit_block_add_assignment_op %s has non-numeric rvalue %s (type: %s)",
gcc::jit::binary_op_reproducer_strings[op],
rvalue->get_debug_string (), rvalue->get_type ()->get_debug_string ());

gcc::jit::recording::statement *stmt = block->add_assignment_op (loc, lvalue, op, rvalue);

Expand Down
Loading