This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

Re: [patch] fix for c++/2416


Any thoughts on this?

Your feedback would be greatly appreciated.

Thanks,

Aleksandar Ristovski
QNX Software Systems


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 <aristovski@qnx.com>


    * gdb.cp/casts.cc: Add class reference variables.
    * gdb.cp/casts.exp: New test cases for up/down casting references.



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 <aristovski@qnx.com>


* 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.




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