aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2019-08-20 09:49:23 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-08-20 09:49:23 +0000
commitf2a35a2fe4a6fef35de549c3aaff120e110cceb8 (patch)
treec19b127d296dc81e352f3d38158f8ea5bca8abae
parentd21ae867a5a83c7c5dd11a2e51d0c4b2ff9e41b8 (diff)
downloadgcc-f2a35a2fe4a6fef35de549c3aaff120e110cceb8.zip
gcc-f2a35a2fe4a6fef35de549c3aaff120e110cceb8.tar.gz
gcc-f2a35a2fe4a6fef35de549c3aaff120e110cceb8.tar.bz2
[Ada] Fix a folding issue with System'To_Address
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. From-SVN: r274726
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/sem_eval.adb14
2 files changed, 16 insertions, 3 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 8ab2edd..e9a8e79 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
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
null array case; used to warn about uncheckedly converting to a
zero-sized array. It is unfortunate that we can't just check
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb
index 78740b9..430b8bd 100644
--- a/gcc/ada/sem_eval.adb
+++ b/gcc/ada/sem_eval.adb
@@ -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