public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sergei Trofimovich" <slyfox@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gcc-patches:master commit in: 10.1.0/gentoo/
Date: Fri,  5 Jun 2020 21:02:05 +0000 (UTC)	[thread overview]
Message-ID: <1591390871.a78ebddd40831f2c95a594a15c59ab7c3c485e83.slyfox@gentoo> (raw)

commit:     a78ebddd40831f2c95a594a15c59ab7c3c485e83
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  5 21:01:11 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Fri Jun  5 21:01:11 2020 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=a78ebddd

10.1.0: fix ICE on constructor range handling

Bug: https://gcc.gnu.org/PR95241
Bug: https://bugs.gentoo.org/726644
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 10.1.0/gentoo/31_all_ctor-range-PR95241.patch | 98 +++++++++++++++++++++++++++
 10.1.0/gentoo/README.history                  |  1 +
 2 files changed, 99 insertions(+)

diff --git a/10.1.0/gentoo/31_all_ctor-range-PR95241.patch b/10.1.0/gentoo/31_all_ctor-range-PR95241.patch
new file mode 100644
index 0000000..2bd166d
--- /dev/null
+++ b/10.1.0/gentoo/31_all_ctor-range-PR95241.patch
@@ -0,0 +1,98 @@
+https://gcc.gnu.org/PR95241
+https://bugs.gentoo.org/726644
+
+From 798a9da416bbfd8996da9a5d53955b082d5b94fe Mon Sep 17 00:00:00 2001
+From: Patrick Palka <ppalka@redhat.com>
+Date: Fri, 29 May 2020 09:44:09 -0400
+Subject: [PATCH] c++: constexpr ctor with RANGE_EXPR index [PR95241]
+
+In the testcase below, the CONSTRUCTOR for 'field' contains a RANGE_EXPR
+index:
+
+  {{aggr_init_expr<...>, [1...2]={.off=1}}}
+
+but get_or_insert_ctor_field isn't prepared to handle looking up a
+RANGE_EXPR index.
+
+This patch adds limited support to get_or_insert_ctor_field for looking
+up a RANGE_EXPR index.  The limited scope of this patch should make it
+more suitable for backporting, and more extensive support would be
+needed only to handle self-modifying CONSTRUCTORs that contain a
+RANGE_EXPR index, but I haven't yet been able to come up with a testcase
+that actually creates such a CONSTRUCTOR.
+
+gcc/cp/ChangeLog:
+
+	PR c++/95241
+	* constexpr.c (get_or_insert_ctor_field): Add limited support
+	for RANGE_EXPR index lookups.
+
+gcc/testsuite/ChangeLog:
+
+	PR c++/95241
+	* g++.dg/cpp0x/constexpr-array25.C: New test.
+
+(cherry picked from commit e069285cdf457cc85070e522380c4e25b0d2ed25)
+---
+ gcc/cp/constexpr.c                            | 16 ++++++++++++++
+ .../g++.dg/cpp0x/constexpr-array25.C          | 21 +++++++++++++++++++
+ 2 files changed, 37 insertions(+)
+ create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-array25.C
+
+diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
+index 706d8a13d8e..3bd2524648d 100644
+--- a/gcc/cp/constexpr.c
++++ b/gcc/cp/constexpr.c
+@@ -3245,6 +3245,22 @@ get_or_insert_ctor_field (tree ctor, tree index, int pos_hint = -1)
+     }
+   else if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == VECTOR_TYPE)
+     {
++      if (TREE_CODE (index) == RANGE_EXPR)
++	{
++	  /* Support for RANGE_EXPR index lookups is currently limited to
++	     accessing an existing element via POS_HINT, or appending a new
++	     element to the end of CTOR.  ??? Support for other access
++	     patterns may also be needed.  */
++	  vec<constructor_elt, va_gc> *elts = CONSTRUCTOR_ELTS (ctor);
++	  if (vec_safe_length (elts))
++	    {
++	      tree lo = TREE_OPERAND (index, 0);
++	      gcc_assert (array_index_cmp (elts->last().index, lo) < 0);
++	    }
++	  CONSTRUCTOR_APPEND_ELT (elts, index, NULL_TREE);
++	  return &elts->last();
++	}
++
+       HOST_WIDE_INT i = find_array_ctor_elt (ctor, index, /*insert*/true);
+       gcc_assert (i >= 0);
+       constructor_elt *cep = CONSTRUCTOR_ELT (ctor, i);
+diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array25.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array25.C
+new file mode 100644
+index 00000000000..9162943249f
+--- /dev/null
++++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array25.C
+@@ -0,0 +1,21 @@
++// PR c++/95241
++// { dg-do compile { target c++11 } }
++
++struct Fragment
++{
++  int off;
++  constexpr Fragment(int _off) : off(_off) { }
++  constexpr Fragment() : Fragment(1) { }
++};
++
++struct Field
++{
++  Fragment fragments[3];
++  constexpr Field(int off) : fragments{{off}} { }
++};
++
++constexpr Field field{0};
++
++static_assert(field.fragments[0].off == 0
++	      && field.fragments[1].off == 1
++	      && field.fragments[2].off == 1, "");
+-- 
+2.27.0
+

diff --git a/10.1.0/gentoo/README.history b/10.1.0/gentoo/README.history
index d7a8c51..deee08f 100644
--- a/10.1.0/gentoo/README.history
+++ b/10.1.0/gentoo/README.history
@@ -1,6 +1,7 @@
 2		TODO
 	+ 29_all_fix-float-hang-PR95118.patch
 	+ 30_all_lto-intl-workaround-PR95194.patch
+	+ 31_all_ctor-range-PR95241.patch
 
 1		05 May 2020
 	+ 01_all_default-fortify-source.patch


             reply	other threads:[~2020-06-05 21:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05 21:02 Sergei Trofimovich [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-07-23  8:50 [gentoo-commits] proj/gcc-patches:master commit in: 10.1.0/gentoo/ Sergei Trofimovich
2020-07-19 21:35 Sergei Trofimovich
2020-07-14  7:17 Sergei Trofimovich
2020-07-04  7:56 Sergei Trofimovich
2020-07-04  7:56 Sergei Trofimovich
2020-07-03 22:12 Sergei Trofimovich
2020-06-24 20:15 Sergei Trofimovich
2020-06-23  6:34 Sergei Trofimovich
2020-06-14 11:07 Sergei Trofimovich
2020-06-11 23:00 Sergei Trofimovich
2020-06-11 22:49 Sergei Trofimovich
2020-05-19 22:02 Sergei Trofimovich
2020-05-14 17:58 Sergei Trofimovich
2020-05-07 20:51 Sergei Trofimovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1591390871.a78ebddd40831f2c95a594a15c59ab7c3c485e83.slyfox@gentoo \
    --to=slyfox@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox