From 239209c4c45b16724b704e68ef8b949d806d3121 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 4 Apr 2018 12:42:33 -0400 Subject: [PATCH] PR c++/85148 - ICE with 'this' in array NSDMI. * tree.c (replace_placeholders_r): Use handled_component_p. From-SVN: r259088 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/tree.c | 2 +- gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr11.C | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr11.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0c71d2bd9de..61483a5fa79 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-04-04 Jason Merrill + + PR c++/85148 - ICE with 'this' in array NSDMI. + * tree.c (replace_placeholders_r): Use handled_component_p. + 2018-04-04 Ville Voutilainen PR c++/65923 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index e75c88d6e8f..7ddc2cb5e2d 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -3145,7 +3145,7 @@ replace_placeholders_r (tree* t, int* walk_subtrees, void* data_) for (; !same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (*t), TREE_TYPE (x)); x = TREE_OPERAND (x, 0)) - gcc_assert (TREE_CODE (x) == COMPONENT_REF); + gcc_assert (handled_component_p (x)); *t = unshare_expr (x); *walk_subtrees = false; d->seen = true; diff --git a/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr11.C b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr11.C new file mode 100644 index 00000000000..09591df3807 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr11.C @@ -0,0 +1,12 @@ +// PR c++/85148 +// { dg-do compile { target c++14 } } + +template struct A +{ + T x[1]{(__PTRDIFF_TYPE__)this}; +}; + +void foo() +{ + A> a{}; +} -- 2.30.2