Skip to content

Commit

Permalink
c++: zero_init_expr_p of dependent expression [PR95678]
Browse files Browse the repository at this point in the history
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 9a453da)
  • Loading branch information
Patrick Palka committed Jun 16, 2020
1 parent 93c2834 commit d986703
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gcc/cp/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 28 additions & 0 deletions gcc/testsuite/g++.dg/cpp0x/dependent3.C
Original file line number Diff line number Diff line change
@@ -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 *>>();
}

0 comments on commit d986703

Please sign in to comment.