C++ PATCH: Fix PR/8031

Gabriel Dos Reis gdr@integrable-solutions.net
Fri Dec 13 14:03:00 GMT 2002


This patchlet fixes PR 8031 (a regression).  Applied to mainline and
branch.  Regtested on an i686-pc-linu-gnu.

-- Gaby
2002-12-13  Gabriel Dos Reis  <gdr@integrable-solutions.net>
	
        PR C++/8031
	* cvt.c (convert_to_pointer_force): Don't try comparing against
	erronous type.

Index: testsuite/g++.dg/conversion/to-virtual-base-1.C
===================================================================
RCS file: testsuite/g++.dg/conversion/to-virtual-base-1.C
diff -N testsuite/g++.dg/conversion/to-virtual-base-1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/conversion/to-virtual-base-1.C	13 Dec 2002 21:49:40 -0000
***************
*** 0 ****
--- 1,15 ----
+ // Copyright (C) 2002 Free Software Foundation
+ // Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
+ 
+ struct A {
+   virtual void f(const A* a) = 0;
+ };
+ 
+ struct B : virtual A {
+   virtual void f(const A* a);
+ };
+ 
+ void B::f(const A* a)
+ {
+   static_cast<const B&>(*a);             // { dg-error "" }
+ }
Index: cp/cvt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cvt.c,v
retrieving revision 1.112.2.4.2.1
diff -p -r1.112.2.4.2.1 cvt.c
*** cp/cvt.c	17 Oct 2002 00:15:37 -0000	1.112.2.4.2.1
--- cp/cvt.c	13 Dec 2002 21:50:32 -0000
*************** convert_to_pointer_force (type, expr)
*** 313,318 ****
--- 313,320 ----
  	  if (binfo)
  	    {
  	      expr = build_base_path (code, expr, binfo, 0);
+ 	      if (expr == error_mark_node)
+ 		return error_mark_node;
  	      /* Add any qualifier conversions. */
  	      if (!same_type_p (TREE_TYPE (TREE_TYPE (expr)),
  				TREE_TYPE (type)))



More information about the Gcc-patches mailing list