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] | |
Tested on i686-linux, committed on trunk
In case of the assignment to a class-wide object, before the assignment we
generate a run-time check to ensure that the tag of the Target is covered
by the tag of the source. For example, considering the following program:
--
procedure Do_Test is
package Pkg is
type Root is abstract tagged null record;
procedure Proc (A: in Root; Output: out Root'Class) is abstract;
type B_T is new Root with record
B_Data : String (1 .. 1024);
end record;
procedure Proc (B: in B_T; Output: out Root'Class);
type C_T is new Root with record
C_Float : Float := 0.0;
end record;
procedure Proc (C: in C_T; Output: out Root'Class);
end Pkg;
package body Pkg is
procedure Proc (B: in B_T; Output: out Root'Class) is
B_Result : B_T;
begin
Output := Root'Class (B_Result); -- 1 --
end Proc;
procedure Proc (C: in C_T; Output: out Root'Class) is
begin
null;
end;
end Pkg;
use Pkg;
B : B_T;
C : C_T;
begin
Proc (B, C);
end Do_Test;
--
Its execution generates the following error at -1-:
raised CONSTRAINT_ERROR : do_test.adb:18 tag check failed
2005-12-05 Javier Miranda <miranda@adacore.com>
* exp_ch5.adb (Expand_N_Assignment_Statement): In case of tagged types
and the assignment to a class-wide object, before the assignment we
generate a run-time check to ensure that the tag of the Target is
covered by the tag of the source.
Attachment:
difs.12
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |