This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH]: Fix 11670


I've installed this patch to fix 11670, we ICE'd rather than issue an
error message.

booted & tested on i686-pc-linux-gnu.

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2003-08-10  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/11670
	* call.c (convert_like_real): Add rvalue binding error message.
	* error.c (dump_expr) <NOP_EXPR case>: Detect when the no expr is
	really a cast.

Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.417
diff -c -3 -p -r1.417 call.c
*** cp/call.c	29 Jul 2003 01:14:22 -0000	1.417
--- cp/call.c	3 Aug 2003 19:00:05 -0000
*************** convert_like_real (tree convs, tree expr
*** 4128,4134 ****
  		  error ("cannot bind packed field `%E' to `%T'",
  			 expr, ref_type);
  		else
! 		  my_friendly_assert (0, 20030715);
  		return error_mark_node;
  	      }
  	    expr = build_target_expr_with_type (expr, type);
--- 4128,4134 ----
  		  error ("cannot bind packed field `%E' to `%T'",
  			 expr, ref_type);
  		else
! 		  error ("cannot bind rvalue `%E' to `%T'", expr, ref_type);
  		return error_mark_node;
  	      }
  	    expr = build_target_expr_with_type (expr, type);
Index: cp/error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.227
diff -c -3 -p -r1.227 error.c
*** cp/error.c	28 Jul 2003 11:06:28 -0000	1.227
--- cp/error.c	3 Aug 2003 19:00:09 -0000
*************** dump_expr (tree t, int flags)
*** 1774,1782 ****
        break;
  
      case NOP_EXPR:
!       dump_expr (TREE_OPERAND (t, 0), flags);
!       break;
! 
      case EXPR_WITH_FILE_LOCATION:
        dump_expr (EXPR_WFL_NODE (t), flags);
        break;
--- 1774,1800 ----
        break;
  
      case NOP_EXPR:
!       {
! 	tree op = TREE_OPERAND (t, 0);
! 	
! 	if (!same_type_p (TREE_TYPE (op), TREE_TYPE (t)))
! 	  {
! 	    /* It is a cast, but we cannot tell whether it is a
! 	       reinterpret or static cast. Use the C style notation.  */
! 	    if (flags & TFF_EXPR_IN_PARENS)
! 	      pp_left_paren (cxx_pp);
! 	    pp_left_paren (cxx_pp);
! 	    dump_type (TREE_TYPE (t), flags);
! 	    pp_right_paren (cxx_pp);
! 	    dump_expr (op, flags | TFF_EXPR_IN_PARENS);
! 	    if (flags & TFF_EXPR_IN_PARENS)
! 	      pp_right_paren (cxx_pp);
! 	  }
! 	else
! 	  dump_expr (op, flags);
! 	break;
!       }
!       
      case EXPR_WITH_FILE_LOCATION:
        dump_expr (EXPR_WFL_NODE (t), flags);
        break;
// { dg-do compile }

// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 3 Aug 2003 <nathan@codesourcery.com>

// PR 11670. ICE on invalid reference binding

struct A {};
struct B : A {};
B b;

B*& f()
{
    A* ap = &b;
    return static_cast<B*>(ap); // { dg-error "cannot bind rvalue" "" }
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]