[Ada] Fix host/target confusion for attribute To_Address

Message ID 20200618091320.GA2087@adacore.com
State New
Headers show
Series
  • [Ada] Fix host/target confusion for attribute To_Address
Related show

Commit Message

Pierre-Marie de Rodat June 18, 2020, 9:13 a.m.
The check applied to the expression of the To_Address attribute in
the case where it is static is done with the address size of the
host instead of the target, resulting in missing error messages.

Tested on x86_64-pc-linux-gnu, committed on trunk

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* sem_attr.adb (Analyze_Attribute) <To_Address>: Use the address
	size of the target instead of the host when checking the value of
	a static expression.  Also use standard idiom for exponentiation.

Patch

--- gcc/ada/sem_attr.adb
+++ gcc/ada/sem_attr.adb
@@ -6274,9 +6274,9 @@  package body Sem_Attr is
          if Is_OK_Static_Expression (E1) then
             Val := Expr_Value (E1);
 
-            if Val < -(2 ** UI_From_Int (Standard'Address_Size - 1))
+            if Val < -(Uint_2 ** (System_Address_Size - 1))
                  or else
-               Val > 2 ** UI_From_Int (Standard'Address_Size) - 1
+               Val > Uint_2 ** System_Address_Size - 1
             then
                Error_Attr ("address value out of range for % attribute", E1);
             end if;
@@ -6293,7 +6293,7 @@  package body Sem_Attr is
             elsif Val < 0 then
                Set_Etype (E1, Universal_Integer);
 
-            --  Otherwise set type to Unsigned_64 to accommodate max values
+            --  Otherwise set type to Unsigned_64 to accommodate large values
 
             else
                Set_Etype (E1, Standard_Unsigned_64);