aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2019-01-30 19:04:05 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2019-01-30 19:04:05 +0000
commit9f4e09a89a4879d1a39f6055b61afb8f335e7604 (patch)
tree9243a3f49aee226a9f591e35d8706ad0fe209f78
parent7341a03ab85827e2fe36c26e6bfad622bdfd218b (diff)
downloadgcc-9f4e09a89a4879d1a39f6055b61afb8f335e7604.zip
gcc-9f4e09a89a4879d1a39f6055b61afb8f335e7604.tar.gz
gcc-9f4e09a89a4879d1a39f6055b61afb8f335e7604.tar.bz2
PR c++/89119 - ICE with value-initialization in template.
* pt.c (tsubst_copy_and_build): Handle RANGE_EXPR. * g++.dg/cpp0x/initlist-value3.C: New test. From-SVN: r268400
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist-value3.C23
4 files changed, 38 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index af4d9c2..4b90951 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-30 Marek Polacek <polacek@redhat.com>
+
+ PR c++/89119 - ICE with value-initialization in template.
+ * pt.c (tsubst_copy_and_build): Handle RANGE_EXPR.
+
2019-01-29 Jason Merrill <jason@redhat.com>
PR c++/86943 - wrong code converting lambda to function pointer.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index cb06a57..f92fa1a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19412,6 +19412,11 @@ tsubst_copy_and_build (tree t,
case REQUIRES_EXPR:
RETURN (tsubst_requires_expr (t, args, complain, in_decl));
+ case RANGE_EXPR:
+ /* No need to substitute further, a RANGE_EXPR will always be built
+ with constant operands. */
+ RETURN (t);
+
case NON_LVALUE_EXPR:
case VIEW_CONVERT_EXPR:
if (location_wrapper_p (t))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3d02efb..8bb5f40 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-30 Marek Polacek <polacek@redhat.com>
+
+ PR c++/89119 - ICE with value-initialization in template.
+ * g++.dg/cpp0x/initlist-value3.C: New test.
+
2019-01-30 Kelvin Nilsen <kelvin@gcc.gnu.org>
* gcc.target/powerpc/vec-extract-schar-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-value3.C b/gcc/testsuite/g++.dg/cpp0x/initlist-value3.C
new file mode 100644
index 0000000..25ac104
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-value3.C
@@ -0,0 +1,23 @@
+// PR c++/89119
+// { dg-do compile { target c++11 } }
+
+struct S { int a[4]; };
+
+template<int N>
+struct R { int a[N]; };
+
+template <typename T>
+void
+fn ()
+{
+ constexpr auto s = S();
+ constexpr auto s2 = S{};
+ constexpr auto r = R<4>();
+ constexpr auto r2 = R<4>{};
+}
+
+void
+foo ()
+{
+ fn<int>();
+}