Skip to content
Snippets Groups Projects
Commit 64828272 authored by Jakub Jelinek's avatar Jakub Jelinek Committed by Jakub Jelinek
Browse files

c++: Fix up maybe_init_list_as_array for RAW_DATA_CST [PR118124]

The previous patch made me look around some more and I found
maybe_init_list_as_array doesn't handle RAW_DATA_CSTs correctly either,
while the RAW_DATA_CST is properly split during finish_compound_literal,
it was using CONSTRUCTOR_NELTS as the size of the arrays, which is wrong,
RAW_DATA_CST could stand for far more initializers.

2025-01-15  Jakub Jelinek  <jakub@redhat.com>

	PR c++/118124
	* cp-tree.h (build_array_of_n_type): Change second argument type
	from int to unsigned HOST_WIDE_INT.
	* tree.cc (build_array_of_n_type): Likewise.
	* call.cc (count_ctor_elements): New function.
	(maybe_init_list_as_array): Use it instead of CONSTRUCTOR_NELTS.
	(convert_like_internal): Use length from init's type instead of
	len when handling the maybe_init_list_as_array case.

	* g++.dg/cpp0x/initlist-opt5.C: New test.
parent f263f2d5
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment