[Ada] Fix wrong type being used for range check generation
authorGhjuvan Lacambre <lacambre@adacore.com>
Fri, 28 Feb 2020 13:56:31 +0000 (14:56 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 9 Jun 2020 08:09:04 +0000 (04:09 -0400)
2020-06-09  Ghjuvan Lacambre  <lacambre@adacore.com>

gcc/ada/

* sem_res.adb (Resolve_Qualified_Expression): Use Subtype_Mark
type.

gcc/ada/sem_res.adb

index 6e26ffb..15d08fe 100644 (file)
@@ -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