From 2abc02a1f5e6078f67172c64b22e91b8a5f1884e Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Sun, 15 Sep 2019 20:22:27 +0000 Subject: [PATCH] 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. * g++.dg/cpp1y/var-templ63.C: New test. From-SVN: r275736 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1y/var-templ63.C | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/var-templ63.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bca30750923..e92d49f1b76 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-09-15 Marek Polacek + + 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 * cp-tree.h (DECL_CLONED_FUNCTION_P): Reimplement using diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 54d28131a01..9de1b8fec97 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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))), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7e10fb42d33..6a5ba09391e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-09-15 Marek Polacek + + PR c++/91740 - ICE with constexpr call and ?: in ARRAY_REF. + * g++.dg/cpp1y/var-templ63.C: New test. + 2019-09-15 Sandra Loosemore * 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 index 00000000000..a65f53b2963 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ63.C @@ -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 const char c = "FOO"[f("BAR") ? 1 : 0]; -- 2.30.2