From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19665 invoked by alias); 31 Mar 2008 18:35:49 -0000 Received: (qmail 19642 invoked by uid 22791); 31 Mar 2008 18:35:46 -0000 X-Spam-Check-By: sourceware.org Received: from qnxmail.qnx.com (HELO nimbus.ott.qnx.com) (209.226.137.76) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 31 Mar 2008 18:35:30 +0000 Received: by nimbus.ott.qnx.com with Internet Mail Service (5.5.2653.19) id <2A1RM2ZD>; Mon, 31 Mar 2008 14:35:26 -0400 Message-ID: <47F12F08.7060304@qnx.com> From: Aleksandar Ristovski To: Daniel Jacobowitz Cc: gdb-patches@sourceware.org Subject: Re: [patch] fix for c++/2416 Date: Mon, 31 Mar 2008 19:01:00 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) user-agent: Content-Type: text/plain; charset="iso-8859-1" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-03/txt/msg00508.txt.bz2 Aleksandar Ristovski wrote: > Daniel Jacobowitz wrote: >> On Thu, Feb 28, 2008 at 01:53:13PM -0500, Aleksandar Ristovski wrote: >>> See revisited diff (attached). Also, please find attached the >>> testcase diff, I added check for reference casting. Do I need to >>> provide change log for tests too? >> >> The testsuite changes look fine but do need a changelog; that >> goes in testsuite/ChangeLog. > > 2008-02-28 Aleksandar Ristovski > > * gdb.cp/casts.cc: Add class reference variables. > * gdb.cp/casts.exp: New test cases for up/down casting references. > Is the testsuite diff (including changelog) ok to commit? The added tests will add 2 more FAIL-s and 2 more PASS-es to the tests, which should turn into 4 more PASS-es, pending the fix to PR2416. > >> >> There's nothing wrong with casting a reference to a non-reference; >> that coerces the reference. Also you have to beware typedefs. >> >> enum type_code code1, code2; >> code1 = TYPE_CODE (check_typedef (value_type (arg1))); >> code2 = TYPE_CODE (check_typedef (value_type (arg2))); >> >> if (code1 == TYPE_CODE_REF && code2 == TYPE_CODE_REF) >> arg1 = value_cast_pointers (type, arg1); >> else if (code1 == TYPE_CODE_REF) >> error (_("Attempt to cast to reference type from non-reference >> type.")); >> else >> arg1 = value_cast (type, arg1); > > Allright, then how about this, yet newer and yet more revisited diff? I > removed changes to eval.c and let it simply call value_cast as it used > to. Now value_cast knows how to handle references. > > > 2008-02-28 Aleksandar Ristovski > > * valops.c (value_cast_structs): New function. Cast related > STRUCT types up/down and return cast value. The body of this > function comes mostly from value_cast_pointers. > (value_cast_pointers): Code for actual cast STRUCT-STRUCT moved > to value_cast_structs. Now value_cast_pointers needs only create > appropriate reference after using value_cast_structs for actual > casting. > (value_cast): Handle references. > > I haven't received any feedback on this.