From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1701695-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 5E5F515802C
	for <garchives@archives.gentoo.org>; Fri, 20 Dec 2024 11:25:30 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 84461E0815;
	Fri, 20 Dec 2024 11:25:29 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 74147E0815
	for <gentoo-commits@lists.gentoo.org>; Fri, 20 Dec 2024 11:25:28 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id A103B335DE9
	for <gentoo-commits@lists.gentoo.org>; Fri, 20 Dec 2024 11:25:27 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 38627EB9
	for <gentoo-commits@lists.gentoo.org>; Fri, 20 Dec 2024 11:25:26 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1734693919.01d33f6be28d09edb2e9aaa66feab7a1b359aa60.sam@gentoo>
Subject: [gentoo-commits] proj/gcc-patches:master commit in: 15.0.0/gentoo/
X-VCS-Repository: proj/gcc-patches
X-VCS-Files: 15.0.0/gentoo/79_all_PR118124-c-Fix-ICEs-with-large-initializer-lists-or-ones-i.patch 15.0.0/gentoo/README.history
X-VCS-Directories: 15.0.0/gentoo/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 01d33f6be28d09edb2e9aaa66feab7a1b359aa60
X-VCS-Branch: master
Date: Fri, 20 Dec 2024 11:25:26 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 1c133cd8-dbe0-41d5-80a1-a9c8d6b276f4
X-Archives-Hash: c42ac24c6e8b9ed6a4aaf5bf1d70c49d

commit:     01d33f6be28d09edb2e9aaa66feab7a1b359aa60
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 20 11:24:56 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Dec 20 11:25:19 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=01d33f6b

15.0.0: fix C++ init ICE

Bug: https://gcc.gnu.org/PR118124
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...Es-with-large-initializer-lists-or-ones-i.patch | 307 +++++++++++++++++++++
 15.0.0/gentoo/README.history                       |   1 +
 2 files changed, 308 insertions(+)

diff --git a/15.0.0/gentoo/79_all_PR118124-c-Fix-ICEs-with-large-initializer-lists-or-ones-i.patch b/15.0.0/gentoo/79_all_PR118124-c-Fix-ICEs-with-large-initializer-lists-or-ones-i.patch
new file mode 100644
index 0000000..ded69c7
--- /dev/null
+++ b/15.0.0/gentoo/79_all_PR118124-c-Fix-ICEs-with-large-initializer-lists-or-ones-i.patch
@@ -0,0 +1,307 @@
+https://inbox.sourceware.org/gcc-patches/Z2U3spZjDr+xEZP0@tucnak/
+
+From b904875837cae597709d37ec45f70c70d353e901 Mon Sep 17 00:00:00 2001
+Message-ID: <b904875837cae597709d37ec45f70c70d353e901.1734693860.git.sam@gentoo.org>
+From: Jakub Jelinek <jakub@redhat.com>
+Date: Fri, 20 Dec 2024 10:24:02 +0100
+Subject: [PATCH] c++, v3: Fix ICEs with large initializer lists or ones
+ including #embed [PR118124]
+
+On Thu, Dec 19, 2024 at 07:01:39PM +0100, Jakub Jelinek wrote:
+> So far lightly tested, ok for trunk this way if it passes bootstrap & testing?
+
+Bootstrap/regtest found an issue, warning about
+  if ()
+    for ()
+      if ()
+      else if ()
+      else
+so I've added {}s around it (no other changes from the previous patch).
+
+Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
+
+2024-12-20  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/118124
+	* call.cc (convert_like_internal): Handle RAW_DATA_CST in
+	ck_list handling.  Formatting fixes.
+
+	* g++.dg/cpp/embed-15.C: New test.
+	* g++.dg/cpp/embed-16.C: New test.
+	* g++.dg/cpp0x/initlist-opt3.C: New test.
+	* g++.dg/cpp0x/initlist-opt4.C: New test.
+---
+ gcc/cp/call.cc                             | 84 ++++++++++++++++++++--
+ gcc/testsuite/g++.dg/cpp/embed-15.C        | 35 +++++++++
+ gcc/testsuite/g++.dg/cpp/embed-16.C        | 18 +++++
+ gcc/testsuite/g++.dg/cpp0x/initlist-opt3.C | 47 ++++++++++++
+ gcc/testsuite/g++.dg/cpp0x/initlist-opt4.C | 20 ++++++
+ 5 files changed, 198 insertions(+), 6 deletions(-)
+ create mode 100644 gcc/testsuite/g++.dg/cpp/embed-15.C
+ create mode 100644 gcc/testsuite/g++.dg/cpp/embed-16.C
+ create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-opt3.C
+ create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-opt4.C
+
+diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
+index c8420db568ea..27cea0db80af 100644
+--- a/gcc/cp/call.cc
++++ b/gcc/cp/call.cc
+@@ -8766,8 +8766,8 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
+ 
+ 	if (tree init = maybe_init_list_as_array (elttype, expr))
+ 	  {
+-	    elttype = cp_build_qualified_type
+-	      (elttype, cp_type_quals (elttype) | TYPE_QUAL_CONST);
++	    elttype = cp_build_qualified_type (elttype, cp_type_quals (elttype)
++							| TYPE_QUAL_CONST);
+ 	    array = build_array_of_n_type (elttype, len);
+ 	    array = build_vec_init_expr (array, init, complain);
+ 	    array = get_target_expr (array);
+@@ -8775,13 +8775,85 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
+ 	  }
+ 	else if (len)
+ 	  {
+-	    tree val; unsigned ix;
+-
++	    tree val;
++	    unsigned ix;
+ 	    tree new_ctor = build_constructor (init_list_type_node, NULL);
+ 
+ 	    /* Convert all the elements.  */
+ 	    FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (expr), ix, val)
+ 	      {
++		if (TREE_CODE (val) == RAW_DATA_CST)
++		  {
++		    tree elt_type;
++		    conversion *next;
++		    /* For conversion to initializer_list<unsigned char> or
++		       initializer_list<char> or initializer_list<signed char>
++		       we can optimize and keep RAW_DATA_CST with adjusted
++		       type if we report narrowing errors if needed, for
++		       others this converts each element separately.  */
++		    if (convs->u.list[ix]->kind == ck_std
++			&& (elt_type = convs->u.list[ix]->type)
++			&& (TREE_CODE (elt_type) == INTEGER_TYPE
++			    || is_byte_access_type (elt_type))
++			&& TYPE_PRECISION (elt_type) == CHAR_BIT
++			&& (next = next_conversion (convs->u.list[ix]))
++			&& next->kind == ck_identity)
++		      {
++			if (!TYPE_UNSIGNED (elt_type)
++			    && (TYPE_UNSIGNED (TREE_TYPE (val))
++				|| (TYPE_PRECISION (TREE_TYPE (val))
++				    > CHAR_BIT)))
++			  for (int i = 0; i < RAW_DATA_LENGTH (val); ++i)
++			    {
++			      if (RAW_DATA_SCHAR_ELT (val, i) >= 0)
++				continue;
++			      else if (complain & tf_error)
++				{
++				  location_t loc
++				    = cp_expr_loc_or_input_loc (val);
++				  int savederrorcount = errorcount;
++				  permerror_opt (loc, OPT_Wnarrowing,
++						 "narrowing conversion of "
++						 "%qd from %qH to %qI",
++						 RAW_DATA_UCHAR_ELT (val, i),
++						 TREE_TYPE (val), elt_type);
++				  if (errorcount != savederrorcount)
++				    return error_mark_node;
++				}
++			      else
++				return error_mark_node;
++			    }
++			tree sub = copy_node (val);
++			TREE_TYPE (sub) = elt_type;
++			CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (new_ctor),
++						NULL_TREE, sub);
++		      }
++		    else
++		      {
++			for (int i = 0; i < RAW_DATA_LENGTH (val); ++i)
++			  {
++			    tree elt
++			      = build_int_cst (TREE_TYPE (val),
++					       RAW_DATA_UCHAR_ELT (val, i));
++			    tree sub
++			      = convert_like (convs->u.list[ix], elt,
++					      fn, argnum, false, false,
++					      /*nested_p=*/true, complain);
++			    if (sub == error_mark_node)
++			      return sub;
++			    if (!check_narrowing (TREE_TYPE (sub), elt,
++						  complain))
++			      return error_mark_node;
++			    tree nc = new_ctor;
++			    CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (nc),
++						    NULL_TREE, sub);
++			    if (!TREE_CONSTANT (sub))
++			      TREE_CONSTANT (new_ctor) = false;
++			  }
++		      }
++		    len += RAW_DATA_LENGTH (val) - 1;
++		    continue;
++		  }
+ 		tree sub = convert_like (convs->u.list[ix], val, fn,
+ 					 argnum, false, false,
+ 					 /*nested_p=*/true, complain);
+@@ -8796,8 +8868,8 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
+ 		  TREE_CONSTANT (new_ctor) = false;
+ 	      }
+ 	    /* Build up the array.  */
+-	    elttype = cp_build_qualified_type
+-	      (elttype, cp_type_quals (elttype) | TYPE_QUAL_CONST);
++	    elttype = cp_build_qualified_type (elttype, cp_type_quals (elttype)
++							| TYPE_QUAL_CONST);
+ 	    array = build_array_of_n_type (elttype, len);
+ 	    array = finish_compound_literal (array, new_ctor, complain);
+ 	    /* This is dubious now, should be blessed by P2752.  */
+diff --git a/gcc/testsuite/g++.dg/cpp/embed-15.C b/gcc/testsuite/g++.dg/cpp/embed-15.C
+new file mode 100644
+index 000000000000..a3994536e576
+--- /dev/null
++++ b/gcc/testsuite/g++.dg/cpp/embed-15.C
+@@ -0,0 +1,35 @@
++// PR c++/118124
++// { dg-do compile { target c++11 } }
++// { dg-options "-O2" }
++
++namespace std {
++template <class T> struct initializer_list {
++private:
++  const T *_M_array;
++  __SIZE_TYPE__ _M_len;
++};
++}
++struct A {
++  A (std::initializer_list<char>);
++};
++A a {
++#embed __FILE__
++};
++struct B {
++  B (std::initializer_list<unsigned char>);
++};
++B b {
++#embed __FILE__
++};
++struct C {
++  C (std::initializer_list<int>);
++};
++C c {
++#embed __FILE__
++};
++struct D {
++  D (std::initializer_list<float>);
++};
++D d {
++#embed __FILE__
++};
+diff --git a/gcc/testsuite/g++.dg/cpp/embed-16.C b/gcc/testsuite/g++.dg/cpp/embed-16.C
+new file mode 100644
+index 000000000000..868dce2f165c
+--- /dev/null
++++ b/gcc/testsuite/g++.dg/cpp/embed-16.C
+@@ -0,0 +1,18 @@
++// PR c++/118124
++// { dg-do compile { target c++11 } }
++// { dg-options "-O2" }
++// non-ASCII chars here: áéí
++
++namespace std {
++template <class T> struct initializer_list {
++private:
++  const T *_M_array;
++  __SIZE_TYPE__ _M_len;
++};
++}
++struct A {
++  A (std::initializer_list<signed char>);
++};
++A a {
++#embed __FILE__
++};	// { dg-error "narrowing conversion of '\[0-9]*' from 'int' to 'signed char'" }
+diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-opt3.C b/gcc/testsuite/g++.dg/cpp0x/initlist-opt3.C
+new file mode 100644
+index 000000000000..fa279882322d
+--- /dev/null
++++ b/gcc/testsuite/g++.dg/cpp0x/initlist-opt3.C
+@@ -0,0 +1,47 @@
++// PR c++/118124
++// { dg-do compile { target c++11 } }
++// { dg-options "-O2" }
++
++namespace std {
++template <class T> struct initializer_list {
++private:
++  const T *_M_array;
++  __SIZE_TYPE__ _M_len;
++};
++}
++struct A {
++  A (std::initializer_list<char>);
++};
++A a { 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7,
++      8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
++      0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1,
++      2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
++      4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
++      6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 };
++struct B {
++  B (std::initializer_list<unsigned char>);
++};
++B b { 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7,
++      8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
++      0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1,
++      2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
++      4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
++      6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 };
++struct C {
++  C (std::initializer_list<int>);
++};
++C c { 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7,
++      8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
++      0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1,
++      2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
++      4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
++      6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 };
++struct D {
++  D (std::initializer_list<float>);
++};
++D d { 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7,
++      8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
++      0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1,
++      2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
++      4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
++      6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 };
+diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-opt4.C b/gcc/testsuite/g++.dg/cpp0x/initlist-opt4.C
+new file mode 100644
+index 000000000000..080dee3cf026
+--- /dev/null
++++ b/gcc/testsuite/g++.dg/cpp0x/initlist-opt4.C
+@@ -0,0 +1,20 @@
++// PR c++/118124
++// { dg-do compile { target c++11 } }
++// { dg-options "-O2" }
++
++namespace std {
++template <class T> struct initializer_list {
++private:
++  const T *_M_array;
++  __SIZE_TYPE__ _M_len;
++};
++}
++struct A {
++  A (std::initializer_list<signed char>);
++};
++A a { 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7,
++      8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
++      0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1,
++      2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 209, 0, 1, 2, 3,
++      4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
++      6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 };	// { dg-error "narrowing conversion of '209' from 'int' to 'signed char'" }
+
+base-commit: 670df03e5294a31efff1554c9a751ef893dc1f71
+-- 
+2.47.1
+

diff --git a/15.0.0/gentoo/README.history b/15.0.0/gentoo/README.history
index dcaecc1..425231d 100644
--- a/15.0.0/gentoo/README.history
+++ b/15.0.0/gentoo/README.history
@@ -3,6 +3,7 @@
 	- 77_all_PR117980-ICE-cxx_eval_outermost_constant_expr.patch
 	+ 77_all_PR118112-c-c-UX-improvements-to-too-few-many-arguments-errors.patch
 	+ 78_all_PR118032-Revert-gimple-Add-limit-after-which-slower-switchlow.patch
+	+ 79_all_PR118124-c-Fix-ICEs-with-large-initializer-lists-or-ones-i.patch
 
 32	16 December 2024