]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix a folding issue with System'To_Address
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Aug 2019 09:49:23 +0000 (09:49 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Aug 2019 09:49:23 +0000 (09:49 +0000)
2019-08-20  Bob Duff  <duff@adacore.com>

gcc/ada/

* sem_eval.adb (Expr_Value): Implement the case of an unchecked
conversion of a static expression.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274726 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/sem_eval.adb

index 8ab2eddd64643dff7a369f00c46ee6fc83a18960..e9a8e79a0dba13f2a16e9681118531b2ac97a05d 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-20  Bob Duff  <duff@adacore.com>
+
+       * sem_eval.adb (Expr_Value): Implement the case of an unchecked
+       conversion of a static expression.
+
 2019-08-20  Bob Duff  <duff@adacore.com>
 
        * sem_ch13.adb (Is_Null_Array): New function, used to detect the
index 78740b956eeaddfbedfb288b29e939a02dce7050..430b8bd5234c64b1b61359a7be2424dc630cb166 100644 (file)
@@ -4281,10 +4281,9 @@ package body Sem_Eval is
          pragma Assert (Is_Access_Type (Underlying_Type (Etype (N))));
          Val := Uint_0;
 
-      --  Otherwise must be character literal
+      --  Character literal
 
-      else
-         pragma Assert (Kind = N_Character_Literal);
+      elsif Kind = N_Character_Literal then
          Ent := Entity (N);
 
          --  Since Character literals of type Standard.Character don't
@@ -4298,6 +4297,15 @@ package body Sem_Eval is
          else
             Val := Enumeration_Pos (Ent);
          end if;
+
+      --  Unchecked conversion, which can come from System'To_Address (X)
+      --  where X is a static integer expression. Recursively evaluate X.
+
+      elsif Kind = N_Unchecked_Type_Conversion then
+         Val := Expr_Value (Expression (N));
+
+      else
+         raise Program_Error;
       end if;
 
       --  Come here with Val set to value to be returned, set cache