c++: zero_init_expr_p of dependent expression
authorPatrick Palka <ppalka@redhat.com>
Thu, 23 Apr 2020 21:26:46 +0000 (17:26 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 23 Apr 2020 21:30:01 +0000 (17:30 -0400)
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
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/dependent3.C [new file with mode: 0644]

index 6506f28..043e6aa 100644 (file)
@@ -1,5 +1,8 @@
 2020-04-23  Patrick Palka  <ppalka@redhat.com>
 
+       * 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.
index 090c565..8840932 100644 (file)
@@ -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);
index e0df5bc..7c6fc64 100644 (file)
@@ -1,5 +1,7 @@
 2020-04-23  Patrick Palka  <ppalka@redhat.com>
 
+       * 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 (file)
index 0000000..caf7e1c
--- /dev/null
@@ -0,0 +1,28 @@
+// { dg-do compile { target c++11 } }
+
+template<typename c>
+struct d
+{
+  using e = c;
+};
+
+template<class f>
+struct g
+{
+  using h = typename d<f>::e;
+
+  template<class i, class j>
+  auto operator()(i, j k) -> decltype(h{k});
+};
+
+template<class l>
+void m()
+{
+  int a[1];
+  l{}(a, a);
+}
+
+int main()
+{
+  m<g<int *>>();
+}