diff options
author | Steve Baird <baird@adacore.com> | 2019-12-12 10:02:51 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-12-12 10:02:51 +0000 |
commit | 16b5f07b5d210a7ae55576043855f50fa72f55db (patch) | |
tree | 5b8363e7055a15423f5e62e9bc3eba82a6ea37a1 /gcc/ada/sem_ch12.adb | |
parent | c9312e3079094e6255f7b5603475f7cd1cb517aa (diff) | |
download | gcc-16b5f07b5d210a7ae55576043855f50fa72f55db.zip gcc-16b5f07b5d210a7ae55576043855f50fa72f55db.tar.gz gcc-16b5f07b5d210a7ae55576043855f50fa72f55db.tar.bz2 |
[Ada] Implement AI12-0036 (a new legality check for instantiations)
2019-12-12 Steve Baird <baird@adacore.com>
gcc/ada/
* sem_ch12.adb
(Instantiate_Type.Validate_Derived_Type_Instance): Implement the
legality check of AI12-0036
From-SVN: r279292
Diffstat (limited to 'gcc/ada/sem_ch12.adb')
-rw-r--r-- | gcc/ada/sem_ch12.adb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 8c3559f..e54e353 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -13166,6 +13166,35 @@ package body Sem_Ch12 is Abandon_Instantiation (Actual); end if; end if; + + -- Don't check Ada_Version here (for now) because AI12-0036 is + -- a binding interpretation; this decision may be reversed if + -- the situation turns out to be similar to that of the preceding + -- Is_Limited_Type test (see preceding comment). + + declare + Formal_Is_Private_Extension : constant Boolean := + Nkind (Parent (A_Gen_T)) = N_Private_Extension_Declaration; + + Actual_Is_Tagged : constant Boolean := Is_Tagged_Type (Act_T); + begin + if Actual_Is_Tagged /= Formal_Is_Private_Extension then + if In_Instance then + null; + else + if Actual_Is_Tagged then + Error_Msg_NE + ("actual for & cannot be a tagged type", + Actual, Gen_T); + else + Error_Msg_NE + ("actual for & must be a tagged type", + Actual, Gen_T); + end if; + Abandon_Instantiation (Actual); + end if; + end if; + end; end Validate_Derived_Type_Instance; ---------------------------------------- |