PR c++/85148 - ICE with 'this' in array NSDMI.
authorJason Merrill <jason@redhat.com>
Wed, 4 Apr 2018 16:42:33 +0000 (12:42 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 4 Apr 2018 16:42:33 +0000 (12:42 -0400)
* tree.c (replace_placeholders_r): Use handled_component_p.

From-SVN: r259088

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr11.C [new file with mode: 0644]

index 0c71d2bd9de82ebde17885109192663e9a149bc5..61483a5fa79ec1599970eb589187f607b1fc32e0 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-04  Jason Merrill  <jason@redhat.com>
+
+       PR c++/85148 - ICE with 'this' in array NSDMI.
+       * tree.c (replace_placeholders_r): Use handled_component_p.
+
 2018-04-04  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        PR c++/65923
index e75c88d6e8f8d8375e5fc214a6d5d2efd69da4e4..7ddc2cb5e2df48b3000a9d60f6b8f540ff80b907 100644 (file)
@@ -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 (file)
index 0000000..09591df
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/85148
+// { dg-do compile { target c++14 } }
+
+template<typename T> struct A
+{
+  T x[1]{(__PTRDIFF_TYPE__)this};
+};
+
+void foo()
+{
+  A<A<__PTRDIFF_TYPE__>> a{};
+}