From 9a453da5cac7b6610cd342a7bea256acba5e61e1 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Thu, 23 Apr 2020 17:26:46 -0400 Subject: [PATCH] c++: zero_init_expr_p of dependent expression This fixes an ICE coming from mangle.c:write_expression when building the testsuite of range-v3; the added testcase is a reduced reproducer for the ICE. gcc/cp/ChangeLog: * tree.c (zero_init_expr_p): Use uses_template_parms instead of dependent_type_p. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/dependent3.C: New test. --- gcc/cp/ChangeLog | 3 +++ gcc/cp/tree.c | 2 +- gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp0x/dependent3.C | 28 +++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/dependent3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6506f288e05..043e6aaddf4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2020-04-23 Patrick Palka + * tree.c (zero_init_expr_p): Use uses_template_parms instead of + dependent_type_p. + PR c++/94645 * pt.c (template_class_depth): Walk into the DECL_FRIEND_CONTEXT of a friend declaration rather than into its CP_DECL_CONTEXT. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 090c565c093..8840932dba2 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -4486,7 +4486,7 @@ bool zero_init_expr_p (tree t) { tree type = TREE_TYPE (t); - if (!type || dependent_type_p (type)) + if (!type || uses_template_parms (type)) return false; if (zero_init_p (type)) return initializer_zerop (t); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e0df5bc0a99..7c6fc644332 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2020-04-23 Patrick Palka + * g++.dg/cpp0x/dependent3.C: New test. + PR c++/94645 * g++.dg/cpp2a/concepts-lambda6.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/dependent3.C b/gcc/testsuite/g++.dg/cpp0x/dependent3.C new file mode 100644 index 00000000000..caf7e1cd4a4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/dependent3.C @@ -0,0 +1,28 @@ +// { dg-do compile { target c++11 } } + +template +struct d +{ + using e = c; +}; + +template +struct g +{ + using h = typename d::e; + + template + auto operator()(i, j k) -> decltype(h{k}); +}; + +template +void m() +{ + int a[1]; + l{}(a, a); +} + +int main() +{ + m>(); +} -- 2.30.2