public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4534] [Ada] Fix type conversion handling in validity checks
@ 2021-10-20 10:17 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-10-20 10:17 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:d9fe0e53d8dbc7cae3170cd6ad783100ec3a704a
commit r12-4534-gd9fe0e53d8dbc7cae3170cd6ad783100ec3a704a
Author: Marc Poulhiès <poulhies@adacore.com>
Date: Fri Oct 8 10:02:11 2021 +0200
[Ada] Fix type conversion handling in validity checks
gcc/ada/
* checks.adb (Insert_Valid_Check): in case of checked type
conversion, update Typ to match Exp's type and add call to
Analyze_And_Resolve.
Diff:
---
gcc/ada/checks.adb | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index a58a49505a9..c06012b57a7 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -8077,7 +8077,7 @@ package body Checks is
Is_High_Bound : Boolean := False)
is
Loc : constant Source_Ptr := Sloc (Expr);
- Typ : constant Entity_Id := Etype (Expr);
+ Typ : Entity_Id := Etype (Expr);
Exp : Node_Id;
begin
@@ -8137,6 +8137,7 @@ package body Checks is
while Nkind (Exp) = N_Type_Conversion loop
Exp := Expression (Exp);
end loop;
+ Typ := Etype (Exp);
-- Do not generate a check for a variable which already validates the
-- value of an assignable object.
@@ -8217,6 +8218,14 @@ package body Checks is
Set_Do_Range_Check (Validated_Object (Var_Id), False);
end if;
+ -- In case of a type conversion, an expansion of the expr may be
+ -- needed (eg. fixed-point as actual).
+
+ if Exp /= Expr then
+ pragma Assert (Nkind (Expr) = N_Type_Conversion);
+ Analyze_And_Resolve (Expr);
+ end if;
+
PV := New_Occurrence_Of (Var_Id, Loc);
-- Otherwise the expression does not denote a variable. Force its
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-20 10:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20 10:17 [gcc r12-4534] [Ada] Fix type conversion handling in validity checks Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).