[Ada] Do not generate VIEW_CONVERT_EXPR for upcasting
Eric Botcazou
ebotcazou@adacore.com
Tue Apr 13 07:21:00 GMT 2010
Unlike the C++ compiler, the Ada compiler generates VIEW_CONVERT_EXPR for even
the simplest upcast:
type Root is tagged null record;
type Derived1 is new Root with record
I1 : Integer;
end record;
R : Root;
D : Derived1;
R := Root(D1);
is tranlated into:
assign ((struct root &) &r, (struct root &) &VIEW_CONVERT_EXPR<struct
root>(d1))
That isn't well defined according to tree.def and unnecessarily cumbersome
compared with the natural:
p___assign ((struct p__root &) &r, (struct p__root &) &d1._parent);
so the attached patch implements the latter form.
Tested on i586-suse-linux, applied on the mainline.
2010-04-13 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/gigi.h (standard_datatypes): Add ADT_parent_name_id.
(parent_name_id): New macro.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: Use it.
* gcc-interface/trans.c (gigi): Initialize it.
(lvalue_required_p) <N_Type_Conversion>: New case.
<N_Qualified_Expression>: Likewise.
<N_Allocator>: Likewise.
* gcc-interface/utils.c (convert): Try to properly upcast tagged types.
2010-04-13 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/derived_type1.adb: New test.
--
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: derived_type1.adb
Type: text/x-adasrc
Size: 650 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100413/bde7d172/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-diff
Size: 5334 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100413/bde7d172/attachment-0001.bin>
More information about the Gcc-patches
mailing list