Hi!

This is Jason's patch from the PR for which I've added a reduced testcase
and bootstrapped/regtested on x86_64-linux and i686-linux.

Ok for trunk and 8.3 (perhaps after a while)?

2018-07-30  Jason Merrill  <ja...@redhat.com>

        PR c++/86706
        * class.c (build_base_path): Use currently_open_class.

        * g++.dg/template/pr86706.C: New test.

--- gcc/cp/class.c.jj   2018-07-30 00:21:26.507313463 +0200
+++ gcc/cp/class.c      2018-07-30 00:22:49.184447971 +0200
@@ -278,6 +278,9 @@ build_base_path (enum tree_code code,
   probe = TYPE_MAIN_VARIANT (TREE_TYPE (expr));
   if (want_pointer)
     probe = TYPE_MAIN_VARIANT (TREE_TYPE (probe));
+  if (dependent_type_p (probe))
+    if (tree open = currently_open_class (probe))
+      probe = open;
 
   if (code == PLUS_EXPR
       && !SAME_BINFO_TYPE_P (BINFO_TYPE (d_binfo), probe))
--- gcc/testsuite/g++.dg/template/pr86706.C.jj  2018-07-30 11:09:33.002035612 
+0200
+++ gcc/testsuite/g++.dg/template/pr86706.C     2018-07-30 11:07:21.069813029 
+0200
@@ -0,0 +1,16 @@
+// PR c++/86706
+// { dg-do compile }
+
+class A { int b; };
+
+template <class, typename>
+class C : A { C (); static C *f; };
+
+template <class T, typename U>
+C<T, U> *C<T, U>::f;
+
+template <class T, typename U>
+C<T, U>::C ()
+{
+  f->b;
+}

        Jakub

Reply via email to