PR c++/79606 - ICE with this->base_member in NSDMI
authorJason Merrill <jason@redhat.com>
Mon, 20 Feb 2017 06:06:20 +0000 (01:06 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 20 Feb 2017 06:06:20 +0000 (01:06 -0500)
* class.c (build_base_path): Check processing_template_decl.

From-SVN: r245593

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/g++.dg/cpp0x/nsdmi-template16.C [new file with mode: 0644]

index 3ae889317f48b63e92200760c99f287a5fc4d408..7258348ec9e06fe825b593a363c10ce024d28457 100644 (file)
@@ -1,5 +1,8 @@
 2017-02-19  Jason Merrill  <jason@redhat.com>
 
+       PR c++/79606 - ICE with this->base_member in NSDMI
+       * class.c (build_base_path): Check processing_template_decl.
+
        PR c++/79607 - ICE with T{} initializer
        * decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR.
 
index 1442b55cfe9246c59fd9e50fc62d455f8b52065d..9e4b4c4fd326429d6699e6cce75da459aad26702 100644 (file)
@@ -375,6 +375,7 @@ build_base_path (enum tree_code code,
      set up properly yet, and the value doesn't matter there either; we're
      just interested in the result of overload resolution.  */
   if (cp_unevaluated_operand != 0
+      || processing_template_decl
       || in_template_function ())
     {
       expr = build_nop (ptr_target_type, expr);
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template16.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template16.C
new file mode 100644 (file)
index 0000000..58dec7b
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/79606
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  int i = 0;
+};
+
+template<int> struct B : A
+{
+  int j = this->i;
+};
+
+B<0> b;