Re: [C++ PATCH] Fix error recovery in tsubst_baselink (PR c++/71826)

2016-07-18 Thread Jason Merrill
OK.

On Mon, Jul 11, 2016 at 3:34 PM, Jakub Jelinek  wrote:
> Hi!
>
> Most of the spots in tsubst_baselink that actually access baselink after
> it has been assigned lookup_fnfields () test that it is a BASELINK_P, except
> one - the BASELINK_OPTYPE update.  lookup_fnfields can return
> error_mark_node though, perhaps something else too.  The patch just follows
> what the surrounding code does.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2016-07-11  Jakub Jelinek  
>
> PR c++/71826
> * pt.c (tsubst_baselink): Only set BASELINK_OPTYPE for BASELINK_P.
>
> * g++.dg/template/pr71826.C: New test.
>
> --- gcc/cp/pt.c.jj  2016-07-11 11:14:28.0 +0200
> +++ gcc/cp/pt.c 2016-07-11 12:30:45.939554745 +0200
> @@ -13734,7 +13734,8 @@ tsubst_baselink (tree baselink, tree obj
>   BASELINK_FUNCTIONS (baselink),
>   template_args);
>  /* Update the conversion operator type.  */
> -BASELINK_OPTYPE (baselink) = optype;
> +if (BASELINK_P (baselink))
> +  BASELINK_OPTYPE (baselink) = optype;
>
>  if (!object_type)
>object_type = current_class_type;
> --- gcc/testsuite/g++.dg/template/pr71826.C.jj  2016-07-11 12:34:51.406568756 
> +0200
> +++ gcc/testsuite/g++.dg/template/pr71826.C 2016-07-11 12:33:35.0 
> +0200
> @@ -0,0 +1,17 @@
> +// PR c++/71826
> +// { dg-do compile }
> +
> +template  struct A { int i; };  // { dg-message "note" }
> +struct B { void i () {} }; // { dg-message "note" }
> +template  struct C : A , B
> +{
> +  void f () { i (); }  // { dg-error "is ambiguous" }
> +};
> +
> +int
> +main ()
> +{
> +  C  c;
> +  c.f ();
> +  return 0;
> +}
>
> Jakub


[C++ PATCH] Fix error recovery in tsubst_baselink (PR c++/71826)

2016-07-11 Thread Jakub Jelinek
Hi!

Most of the spots in tsubst_baselink that actually access baselink after
it has been assigned lookup_fnfields () test that it is a BASELINK_P, except
one - the BASELINK_OPTYPE update.  lookup_fnfields can return
error_mark_node though, perhaps something else too.  The patch just follows
what the surrounding code does.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-07-11  Jakub Jelinek  

PR c++/71826
* pt.c (tsubst_baselink): Only set BASELINK_OPTYPE for BASELINK_P.

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

--- gcc/cp/pt.c.jj  2016-07-11 11:14:28.0 +0200
+++ gcc/cp/pt.c 2016-07-11 12:30:45.939554745 +0200
@@ -13734,7 +13734,8 @@ tsubst_baselink (tree baselink, tree obj
  BASELINK_FUNCTIONS (baselink),
  template_args);
 /* Update the conversion operator type.  */
-BASELINK_OPTYPE (baselink) = optype;
+if (BASELINK_P (baselink))
+  BASELINK_OPTYPE (baselink) = optype;
 
 if (!object_type)
   object_type = current_class_type;
--- gcc/testsuite/g++.dg/template/pr71826.C.jj  2016-07-11 12:34:51.406568756 
+0200
+++ gcc/testsuite/g++.dg/template/pr71826.C 2016-07-11 12:33:35.0 
+0200
@@ -0,0 +1,17 @@
+// PR c++/71826
+// { dg-do compile }
+
+template  struct A { int i; };  // { dg-message "note" }
+struct B { void i () {} }; // { dg-message "note" }
+template  struct C : A , B
+{ 
+  void f () { i (); }  // { dg-error "is ambiguous" }
+};
+
+int
+main ()
+{ 
+  C  c;
+  c.f ();
+  return 0;
+}

Jakub