]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Preserve original CE reason in more cases
authorArnaud Charlet <charlet@adacore.com>
Tue, 17 Jul 2018 08:12:51 +0000 (08:12 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 17 Jul 2018 08:12:51 +0000 (08:12 +0000)
2018-07-17  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* sem_eval.adb (Rewrite_In_Raise_CE): Keep the original reason in more
cases.

From-SVN: r262802

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

index 38db4d6189d225956a9b986f4177ff7efc7e22bd..21b7bb897fcda70fecd64d768be0b23a02f2ce14 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-17  Arnaud Charlet  <charlet@adacore.com>
+
+       * sem_eval.adb (Rewrite_In_Raise_CE): Keep the original reason in more
+       cases.
+
 2018-07-17  Arnaud Charlet  <charlet@adacore.com>
 
        * checks.adb (Apply_Division_Check): Add provision for floating-point
index 2bdf73d72de660385577403689dc2de579341525..51094cd17303f027c6cca12c6276420c94349cc2 100644 (file)
@@ -5707,9 +5707,16 @@ package body Sem_Eval is
       --  Else build an explicit N_Raise_CE
 
       else
-         Rewrite (N,
-           Make_Raise_Constraint_Error (Sloc (Exp),
-             Reason => CE_Range_Check_Failed));
+         if Nkind (Exp) = N_Raise_Constraint_Error then
+            Rewrite (N,
+              Make_Raise_Constraint_Error (Sloc (Exp),
+                Reason => Reason (Exp)));
+         else
+            Rewrite (N,
+              Make_Raise_Constraint_Error (Sloc (Exp),
+                Reason => CE_Range_Check_Failed));
+         end if;
+
          Set_Raises_Constraint_Error (N);
          Set_Etype (N, Typ);
       end if;