public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9403] gimplify: Gimplify value in gimplify_init_ctor_eval_range [PR98353]
@ 2021-04-20 23:30 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2021-04-20 23:30 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:202240b05f28681053c64efbf1e6deb07f36e1b8

commit r9-9403-g202240b05f28681053c64efbf1e6deb07f36e1b8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Dec 22 00:01:34 2020 +0100

    gimplify: Gimplify value in gimplify_init_ctor_eval_range [PR98353]
    
    gimplify_init_ctor_eval_range wasn't gimplifying value, so if it wasn't
    a gimple val, verification at the end of gimplification would ICE (or with
    release checking some random pass later on would ICE or misbehave).
    
    2020-12-21  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/98353
            * gimplify.c (gimplify_init_ctor_eval_range): Gimplify value before
            storing it into cref.
    
            * g++.dg/opt/pr98353.C: New test.
    
    (cherry picked from commit f3113a85f098df8165624321cc85d20219fb2ada)

Diff:
---
 gcc/gimplify.c                     |  6 +++++-
 gcc/testsuite/g++.dg/opt/pr98353.C | 17 +++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 8c30910d90d..ae3cd1a3828 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4497,7 +4497,11 @@ gimplify_init_ctor_eval_range (tree object, tree lower, tree upper,
     gimplify_init_ctor_eval (cref, CONSTRUCTOR_ELTS (value),
 			     pre_p, cleared);
   else
-    gimplify_seq_add_stmt (pre_p, gimple_build_assign (cref, value));
+    {
+      if (gimplify_expr (&value, pre_p, NULL, is_gimple_val, fb_rvalue)
+	  != GS_ERROR)
+	gimplify_seq_add_stmt (pre_p, gimple_build_assign (cref, value));
+    }
 
   /* We exit the loop when the index var is equal to the upper bound.  */
   gimplify_seq_add_stmt (pre_p,
diff --git a/gcc/testsuite/g++.dg/opt/pr98353.C b/gcc/testsuite/g++.dg/opt/pr98353.C
new file mode 100644
index 00000000000..e3d0a4765b4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr98353.C
@@ -0,0 +1,17 @@
+// PR c++/98353
+// { dg-do compile { target c++11 } }
+
+template <int N> struct A {};
+template <typename T>
+struct B
+{
+  static const int n = 1;
+  template <class> A <B<T>::n> foo ();
+  _Complex double c[2], d = 1.0;
+};
+
+void
+bar ()
+{
+  B<int>().foo<int> ();
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-20 23:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20 23:30 [gcc r9-9403] gimplify: Gimplify value in gimplify_init_ctor_eval_range [PR98353] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).