PR c++/91740 - ICE with constexpr call and ?: in ARRAY_REF.
authorMarek Polacek <polacek@redhat.com>
Sun, 15 Sep 2019 20:22:27 +0000 (20:22 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Sun, 15 Sep 2019 20:22:27 +0000 (20:22 +0000)
* pt.c (build_non_dependent_expr): Call build_non_dependent_expr for
the first operand.

* g++.dg/cpp1y/var-templ63.C: New test.

From-SVN: r275736

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/var-templ63.C [new file with mode: 0644]

index bca30750923a956f650a76899a87a4e11fcb71e8..e92d49f1b766f043be183c30841350f35d1a0b60 100644 (file)
@@ -1,3 +1,9 @@
+2019-09-15  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/91740 - ICE with constexpr call and ?: in ARRAY_REF.
+       * pt.c (build_non_dependent_expr): Call build_non_dependent_expr for
+       the first operand.
+
 2019-09-15  Nathan Sidwell  <nathan@acm.org>
 
        * cp-tree.h (DECL_CLONED_FUNCTION_P): Reimplement using
index 54d28131a0180c06f928de084188a7568858f3eb..9de1b8fec979e094a153848705113d385ffeaca5 100644 (file)
@@ -26710,7 +26710,7 @@ build_non_dependent_expr (tree expr)
   if (TREE_CODE (expr) == COND_EXPR)
     return build3 (COND_EXPR,
                   TREE_TYPE (expr),
-                  TREE_OPERAND (expr, 0),
+                  build_non_dependent_expr (TREE_OPERAND (expr, 0)),
                   (TREE_OPERAND (expr, 1)
                    ? build_non_dependent_expr (TREE_OPERAND (expr, 1))
                    : build_non_dependent_expr (TREE_OPERAND (expr, 0))),
index 7e10fb42d33cb9b207e6e9e5456a324b768bf00d..6a5ba09391e63d415de2d36144187466e3eeaf94 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-15  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/91740 - ICE with constexpr call and ?: in ARRAY_REF.
+       * g++.dg/cpp1y/var-templ63.C: New test.
+
 2019-09-15  Sandra Loosemore  <sandra@codesourcery.com>
 
        * lib/target-supports.exp
diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ63.C b/gcc/testsuite/g++.dg/cpp1y/var-templ63.C
new file mode 100644 (file)
index 0000000..a65f53b
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/91740 - ICE with constexpr call and ?: in ARRAY_REF.
+// { dg-do compile { target c++14 } }
+
+constexpr bool f(const char*) { return true; }
+template<typename T> const char c = "FOO"[f("BAR") ? 1 : 0];