From 10212bd8f06e0f8577e15883cae6f9b7c5f381d8 Mon Sep 17 00:00:00 2001 From: Ghjuvan Lacambre Date: Fri, 28 Feb 2020 14:56:31 +0100 Subject: [PATCH] [Ada] Fix wrong type being used for range check generation 2020-06-09 Ghjuvan Lacambre gcc/ada/ * sem_res.adb (Resolve_Qualified_Expression): Use Subtype_Mark type. --- gcc/ada/sem_res.adb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 6e26ffb3c45..15d08fee4fc 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -10004,8 +10004,10 @@ package body Sem_Res is -- check may convert an illegal static expression and result in warning -- rather than giving an error (e.g Integer'(Integer'Last + 1)). - if Nkind (N) = N_Qualified_Expression and then Is_Scalar_Type (Typ) then - Apply_Scalar_Range_Check (Expr, Typ); + if Nkind (N) = N_Qualified_Expression + and then Is_Scalar_Type (Target_Typ) + then + Apply_Scalar_Range_Check (Expr, Target_Typ); end if; -- AI12-0100: Once the qualified expression is resolved, check whether -- 2.30.2