]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: zero_init_expr_p of dependent expression [PR95678]
authorPatrick Palka <ppalka@redhat.com>
Tue, 16 Jun 2020 16:16:02 +0000 (12:16 -0400)
committerPatrick Palka <ppalka@redhat.com>
Tue, 16 Jun 2020 16:16:02 +0000 (12:16 -0400)
gcc/cp/ChangeLog:

PR c++/95678
* tree.c (zero_init_expr_p): Use uses_template_parms instead of
dependent_type_p.

gcc/testsuite/ChangeLog:

PR c++/95678
* g++.dg/cpp0x/dependent3.C: New test.

(cherry picked from commit 9a453da5cac7b6610cd342a7bea256acba5e61e1)

gcc/cp/tree.c
gcc/testsuite/g++.dg/cpp0x/dependent3.C [new file with mode: 0644]

index 1614f346a59f8c721f75feb6784b1938b52c586d..7c68706640c5b8c3360d9a314fbc544205df9631 100644 (file)
@@ -4384,7 +4384,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/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 *>>();
+}