diff options
author | Ed Schonberg <schonberg@adacore.com> | 2018-09-26 09:18:52 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-09-26 09:18:52 +0000 |
commit | 6cd1ee98eaf775b062c90cb1ef0dc777c086afc2 (patch) | |
tree | 48ec6bb21378f378e57d68460d582c5e90fa6fed /gcc/ada | |
parent | abbfd69841b2357d242d47abda8d0430269ab829 (diff) | |
download | gcc-6cd1ee98eaf775b062c90cb1ef0dc777c086afc2.zip gcc-6cd1ee98eaf775b062c90cb1ef0dc777c086afc2.tar.gz gcc-6cd1ee98eaf775b062c90cb1ef0dc777c086afc2.tar.bz2 |
[Ada] Spurious error on private extension with predicate
This patch fixes a spurious error involving a private extension whose
full view includes a dynamic predicate, when the parent type is itself
private at the point of the predicate check. The conversion is known to
be legal so no extra conversion checks are required.
2018-09-26 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* exp_util.adb (Make_Predicate_Call): Use OK_Convert_To when
applying a predicate check to prevent spurious errors when
private ancestors are involved.
gcc/testsuite/
* gnat.dg/predicate2-containers.ads,
gnat.dg/predicate2-project-name_values.ads,
gnat.dg/predicate2-project-registry-attribute.ads,
gnat.dg/predicate2-project-registry.ads,
gnat.dg/predicate2-project-typ-set.ads,
gnat.dg/predicate2-project-typ.ads,
gnat.dg/predicate2-project.ads,
gnat.dg/predicate2-source_reference.ads, gnat.dg/predicate2.ads,
gnat.dg/predicate2_main.adb: New testcase.
From-SVN: r264626
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/exp_util.adb | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d549a87..9731513 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2018-09-26 Ed Schonberg <schonberg@adacore.com> + + * exp_util.adb (Make_Predicate_Call): Use OK_Convert_To when + applying a predicate check to prevent spurious errors when + private ancestors are involved. + 2018-09-26 Hristian Kirtchev <kirtchev@adacore.com> * exp_ch4.adb (Expand_N_Allocator): Ensure that the use of the diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index ec681af..cf277c1 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -9313,14 +9313,16 @@ package body Exp_Util is -- If the type is tagged, the expression may be class-wide, in which -- case it has to be converted to its root type, given that the - -- generated predicate function is not dispatching. + -- generated predicate function is not dispatching. The conversion + -- is type-safe and does not need validation, which matters when + -- private extensions are involved. if Is_Tagged_Type (Typ) then Call := Make_Function_Call (Loc, Name => New_Occurrence_Of (Func_Id, Loc), Parameter_Associations => - New_List (Convert_To (Typ, Relocate_Node (Expr)))); + New_List (OK_Convert_To (Typ, Relocate_Node (Expr)))); else Call := Make_Function_Call (Loc, |