diff options
author | Ed Schonberg <schonberg@adacore.com> | 2019-07-01 13:37:47 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-01 13:37:47 +0000 |
commit | d21c7dd6a2cf854da4776082cc6903acbdf8391f (patch) | |
tree | bad13ae0930e056837e7a5850e4f592197534b5a /gcc/ada | |
parent | 6578a6bfec1ae4a6a077055ebf0024e0079b80f7 (diff) | |
download | gcc-d21c7dd6a2cf854da4776082cc6903acbdf8391f.zip gcc-d21c7dd6a2cf854da4776082cc6903acbdf8391f.tar.gz gcc-d21c7dd6a2cf854da4776082cc6903acbdf8391f.tar.bz2 |
[Ada] Spurious error on inst. of partially defaulted formal package
This patch removes a spurious error on an instantiation whose generic
unit has a formal package where some formal parameters are
box-initialiaed. Previously the code assumed that box-initialization
for a formal package applied to all its formal parameters.
2019-07-01 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch12.adb (Is_Defaulted): New predicate in
Check_Formal_Package_Intance, to skip the conformance of checks
on parameters of a formal package that are defaulted,
gcc/testsuite/
* gnat.dg/generic_inst3.adb,
gnat.dg/generic_inst3_kafka_lib-topic.ads,
gnat.dg/generic_inst3_kafka_lib.ads,
gnat.dg/generic_inst3_markets.ads,
gnat.dg/generic_inst3_traits-encodables.ads,
gnat.dg/generic_inst3_traits.ads: New testcase.
From-SVN: r272883
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/sem_ch12.adb | 35 |
2 files changed, 41 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 51ff642..6396196 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-07-01 Ed Schonberg <schonberg@adacore.com> + + * sem_ch12.adb (Is_Defaulted): New predicate in + Check_Formal_Package_Intance, to skip the conformance of checks + on parameters of a formal package that are defaulted, + 2019-07-01 Hristian Kirtchev <kirtchev@adacore.com> * checks.adb, exp_ch9.adb, exp_unst.adb, sem_ch4.adb, diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 0395af9..9ddfc97 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -6195,6 +6195,12 @@ package body Sem_Ch12 is -- Common error routine for mismatch between the parameters of the -- actual instance and those of the formal package. + function Is_Defaulted (Param : Entity_Id) return Boolean; + -- If the formql package has partly box-initialized formals, skip + -- conformace check for these formals. Previously the code assumed + -- that boc initialization for a formal package applied to all + -- its formal parameters. + function Same_Instantiated_Constant (E1, E2 : Entity_Id) return Boolean; -- The formal may come from a nested formal package, and the actual may -- have been constant-folded. To determine whether the two denote the @@ -6245,6 +6251,32 @@ package body Sem_Ch12 is end if; end Check_Mismatch; + ------------------ + -- Is_Defaulted -- + ------------------ + + function Is_Defaulted (Param : Entity_Id) return Boolean is + Assoc : Node_Id; + begin + Assoc := First (Generic_Associations + (Parent (Associated_Formal_Package (Actual_Pack)))); + + while Present (Assoc) loop + if Nkind (Assoc) = N_Others_Choice then + return True; + + elsif Nkind (Assoc) = N_Generic_Association + and then Chars (Selector_Name (Assoc)) = Chars (Param) + then + return Box_Present (Assoc); + end if; + + Next (Assoc); + end loop; + + return False; + end Is_Defaulted; + -------------------------------- -- Same_Instantiated_Constant -- -------------------------------- @@ -6414,6 +6446,9 @@ package body Sem_Ch12 is then goto Next_E; + elsif Is_Defaulted (E1) then + goto Next_E; + elsif Is_Type (E1) then -- Subtypes must statically match. E1, E2 are the local entities |