diff options
author | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2017-10-09 18:23:07 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2017-10-09 18:23:07 +0000 |
commit | 5d57846b76a90d2a1f12b519afdb636851a15e90 (patch) | |
tree | 38ff92e8ad71a71e6fd37742318ecea0e136146a /gcc/ada | |
parent | a1df65216abc657e2bc941ede69eeb225e7bd224 (diff) | |
download | gcc-5d57846b76a90d2a1f12b519afdb636851a15e90.zip gcc-5d57846b76a90d2a1f12b519afdb636851a15e90.tar.gz gcc-5d57846b76a90d2a1f12b519afdb636851a15e90.tar.bz2 |
exp_ch6.adb: (Make_Build_In_Place_Call_In_Object_Declaration): Take care of unchecked...
gcc/ada/
2017-10-09 Bob Duff <duff@adacore.com>
* exp_ch6.adb: (Make_Build_In_Place_Call_In_Object_Declaration): Take
care of unchecked conversions in addition to regular conversions. This
takes care of a case where a type is derived from a private untagged
type that is completed by a tagged controlled type.
2017-10-09 Ed Schonberg <schonberg@adacore.com>
* exp_disp.adb (Build_Class_Wide_Check, Replace_Formals): When
rewriting a class-wide condition, handle properly the case where the
controlling argument of the operation to which the condition applies is
an access to a tagged type, and the condition includes a dispatching
call with an implicit dereference.
gcc/testsuite/
2017-10-09 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/class_wide4.adb, gnat.dg/class_wide4_pkg.ads,
gnat.dg/class_wide4_pkg2.ads: New testcase.
From-SVN: r253554
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/ada/exp_ch6.adb | 4 | ||||
-rw-r--r-- | gcc/ada/exp_disp.adb | 12 |
3 files changed, 30 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index cba97a1..ff6392a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,20 @@ 2017-10-09 Bob Duff <duff@adacore.com> + * exp_ch6.adb: (Make_Build_In_Place_Call_In_Object_Declaration): Take + care of unchecked conversions in addition to regular conversions. This + takes care of a case where a type is derived from a private untagged + type that is completed by a tagged controlled type. + +2017-10-09 Ed Schonberg <schonberg@adacore.com> + + * exp_disp.adb (Build_Class_Wide_Check, Replace_Formals): When + rewriting a class-wide condition, handle properly the case where the + controlling argument of the operation to which the condition applies is + an access to a tagged type, and the condition includes a dispatching + call with an implicit dereference. + +2017-10-09 Bob Duff <duff@adacore.com> + * exp_ch6.adb: (Make_Build_In_Place_Call_In_Object_Declaration): Remove the code at the end of this procedure that was setting the type of a class-wide object to the specific type returned by a function call. diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index f0afc1e..beb0291 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -8466,7 +8466,9 @@ package body Exp_Ch6 is Set_Etype (Def_Id, Ptr_Typ); Set_Is_Known_Non_Null (Def_Id); - if Nkind (Function_Call) = N_Type_Conversion then + if Nkind_In + (Function_Call, N_Type_Conversion, N_Unchecked_Type_Conversion) + then Res_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Def_Id, diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index 80276a9..63c996e 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -736,6 +736,18 @@ package body Exp_Disp is if Is_Class_Wide_Type (Etype (F)) then Set_Etype (N, Etype (F)); + + -- Conversely, if this is a controlling argument + -- (in a dispatching call in the condition) + -- that is a dereference, the source is an access to + -- classwide type, so preserve the dispatching nature + -- of the call in the rewritten condition. + + elsif Nkind (Parent (N)) = N_Explicit_Dereference + and then Is_Controlling_Actual (Parent (N)) + then + Set_Controlling_Argument (Parent (Parent (N)), + Parent (N)); end if; exit; |