@@ -2143,6 +2143,7 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
2143
2143
opstack_push (compound_var );
2144
2144
add_insn (parent , * bb , OP_load_constant , compound_var , NULL ,
2145
2145
NULL , 0 , NULL );
2146
+ return ;
2146
2147
} else if (cast_or_literal_type -> base_type == TYPE_struct ||
2147
2148
cast_or_literal_type -> base_type == TYPE_typedef ) {
2148
2149
/* Struct compound literal support (following proposed solution
@@ -2258,21 +2259,14 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
2258
2259
/* Store first element value for array-to-scalar */
2259
2260
compound_var -> init_val = first_element -> init_val ;
2260
2261
2261
- /* Create result that provides first element access .
2262
- * This enables array compound literals in scalar
2263
- * contexts: int x = (int[]){1,2,3}; // x gets 1 int y
2264
- * = 5 + (int[]){10 }; // adds 5 + 10
2262
+ /* Return the array itself, let normal array decay handle conversion .
2263
+ * This enables both scalar and pointer contexts:
2264
+ * int x = (int[]){1,2,3}; // array decays to first element
2265
+ * int *p = (int[]){1,2,3 }; // array decays to pointer
2265
2266
*/
2266
- var_t * result_var = require_var (parent );
2267
- gen_name_to (result_var -> var_name );
2268
- result_var -> type = compound_var -> type ;
2269
- result_var -> ptr_level = 0 ;
2270
- result_var -> array_size = 0 ;
2271
-
2272
- /* Read first element from the array */
2273
- add_insn (parent , * bb , OP_read , result_var , compound_var ,
2274
- NULL , compound_var -> type -> size , NULL );
2275
- opstack_push (result_var );
2267
+ compound_var -> array_size = element_count ;
2268
+ compound_var -> ptr_level = 0 ;
2269
+ opstack_push (compound_var );
2276
2270
} else {
2277
2271
/* Single value: (int){42} - scalar compound literal */
2278
2272
compound_var = opstack_pop ();
0 commit comments