diff --git a/gcc/testsuite/jit.dg/test-local-init-rvalue.c b/gcc/testsuite/jit.dg/test-local-init-rvalue.c index 1d74679c07c..308f5c39538 100644 --- a/gcc/testsuite/jit.dg/test-local-init-rvalue.c +++ b/gcc/testsuite/jit.dg/test-local-init-rvalue.c @@ -456,12 +456,42 @@ create_code (gcc_jit_context *ctxt, void *user_data) 0, gcc_jit_lvalue_as_rvalue(local)); } - { /* int[50] foo() { int arr[50]; + { /* int [50] foobar = {1,2,3,4}; + int[50] foo() { int arr[50]; + arr = (int [50]){-1,-2,-3,-4,-5,-6}; + arr = foobar; arr = (int [50]){1,2,3,4,5,6}; + arr[6] = 1234; return arr;} N.B: Not a typo, returning an array. */ + + gcc_jit_rvalue *rval_1 = gcc_jit_context_new_rvalue_from_int ( + ctxt, int_type, 1); + gcc_jit_rvalue *rval_2 = gcc_jit_context_new_rvalue_from_int ( + ctxt, int_type, 2); + gcc_jit_rvalue *rval_3 = gcc_jit_context_new_rvalue_from_int ( + ctxt, int_type, 3); + gcc_jit_rvalue *rval_4 = gcc_jit_context_new_rvalue_from_int ( + ctxt, int_type, 4); + + gcc_jit_rvalue *values4[] = {rval_1, rval_2, rval_3, rval_4}; + + gcc_jit_rvalue *ctor3 = + gcc_jit_context_new_array_constructor (ctxt, + 0, + int50arr_type, + 4, + values4); + gcc_jit_lvalue *global_intarr_1234 = + gcc_jit_context_new_global (ctxt, NULL, + GCC_JIT_GLOBAL_EXPORTED, + int50arr_type, + "foobar"); + + gcc_jit_global_set_initializer_rvalue (global_intarr_1234, ctor3); + gcc_jit_function *fn = gcc_jit_context_new_function (ctxt, 0, @@ -471,11 +501,19 @@ create_code (gcc_jit_context *ctxt, void *user_data) 0, 0, 0); + gcc_jit_lvalue *local = gcc_jit_function_new_local (fn, 0, int50arr_type, "local"); + /* + gcc_jit_lvalue *local = + gcc_jit_context_new_global (ctxt, + 0, GCC_JIT_GLOBAL_EXPORTED, + int50arr_type, + "local"); + */ gcc_jit_block *block = gcc_jit_function_new_block (fn, "start"); gcc_jit_rvalue *values[6]; @@ -490,8 +528,37 @@ create_code (gcc_jit_context *ctxt, void *user_data) 6, values); + gcc_jit_rvalue *values2[6]; + + for (int i = 0; i < 6; i++) + values2[i] = gcc_jit_context_new_rvalue_from_int (ctxt, int_type, -i - 1); + + gcc_jit_rvalue *ctor2 = gcc_jit_context_new_array_constructor ( + ctxt, + 0, + int50arr_type, + 6, + values2); + + gcc_jit_block_add_assignment ( + block, 0, local, + gcc_jit_lvalue_as_rvalue (global_intarr_1234)); + gcc_jit_block_add_assignment (block, 0, local, ctor2); gcc_jit_block_add_assignment (block, 0, local, ctor); + gcc_jit_lvalue *arr_access = + gcc_jit_context_new_array_access (ctxt, 0, + gcc_jit_lvalue_as_rvalue (local), + gcc_jit_context_new_rvalue_from_int ( + ctxt, + int_type, + 6)); + gcc_jit_block_add_assignment (block, 0, arr_access, + gcc_jit_context_new_rvalue_from_int ( + ctxt, + int_type, + 1234)); + gcc_jit_block_end_with_return (block, 0, gcc_jit_lvalue_as_rvalue(local)); @@ -696,7 +763,7 @@ verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) struct int50arr (*fn) (void) = gcc_jit_result_get_code (result, "fn_int50arr_123s"); struct int50arr ans = fn (); - int key[50] = {1,2,3,4,5,6}; + int key[50] = {1,2,3,4,5,6, 1234}; CHECK_VALUE (memcmp (ans.arr, key, sizeof (key)), 0); }