[C++] Fix ICE in build_base_path (PR c++/86706)

Message ID 20180803094501.GM17988@tucnak
State New
Headers show
Series
  • [C++] Fix ICE in build_base_path (PR c++/86706)
Related show

Commit Message

Jakub Jelinek Aug. 3, 2018, 9:45 a.m.
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  <jason@redhat.com>

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

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


	Jakub

Comments

Nathan Sidwell Aug. 3, 2018, 2:56 p.m. | #1
On 08/03/2018 02:45 AM, Jakub Jelinek wrote:
> 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  <jason@redhat.com>
> 
> 	PR c++/86706
> 	* class.c (build_base_path): Use currently_open_class.
> 
> 	* g++.dg/template/pr86706.C: New test.
> 

Ok

nathan

Patch

--- 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;
+}