public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/guojiufu/heads/personal-branch)] [Ada] Do not set the bounds of integer types to be universal
@ 2020-06-10 3:24 Jiu Fu Guo
0 siblings, 0 replies; only message in thread
From: Jiu Fu Guo @ 2020-06-10 3:24 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:25d744bb6cf7e3b9a91930caff9f88814f2c36ca
commit 25d744bb6cf7e3b9a91930caff9f88814f2c36ca
Author: Eric Botcazou <ebotcazou@adacore.com>
Date: Tue Dec 10 11:20:06 2019 +0100
[Ada] Do not set the bounds of integer types to be universal
2020-06-02 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* sem_ch3.adb (Signed_Integer_Type_Declaration): Change the type
of the bounds from Universal_Integer to Implicit_Base.
Diff:
---
gcc/ada/sem_ch3.adb | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index f965e8ca6cf..e792072b45f 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -22550,18 +22550,10 @@ package body Sem_Ch3 is
("non-static expression used for integer type bound!", Expr);
Errs := True;
- -- The bounds are folded into literals, and we set their type to be
- -- universal, to avoid typing difficulties: we cannot set the type
- -- of the literal to the new type, because this would be a forward
- -- reference for the back end, and if the original type is user-
- -- defined this can lead to spurious semantic errors (e.g. 2928-003).
+ -- Otherwise the bounds are folded into literals
- else
- if Is_Entity_Name (Expr) then
- Fold_Uint (Expr, Expr_Value (Expr), True);
- end if;
-
- Set_Etype (Expr, Universal_Integer);
+ elsif Is_Entity_Name (Expr) then
+ Fold_Uint (Expr, Expr_Value (Expr), True);
end if;
end Check_Bound;
@@ -22583,6 +22575,7 @@ package body Sem_Ch3 is
if Hi = Error or else Lo = Error then
Base_Typ := Any_Integer;
Set_Error_Posted (T, True);
+ Errs := True;
-- Here both bounds are OK expressions
@@ -22627,6 +22620,17 @@ package body Sem_Ch3 is
end if;
end if;
+ -- Set the type of the bounds to the implicit base: we cannot set it to
+ -- the new type, because this would be a forward reference for the code
+ -- generator and, if the original type is user-defined, this could even
+ -- lead to spurious semantic errors. Furthermore we do not set it to be
+ -- universal, because this could make it much larger than needed here.
+
+ if not Errs then
+ Set_Etype (Lo, Implicit_Base);
+ Set_Etype (Hi, Implicit_Base);
+ end if;
+
-- Complete both implicit base and declared first subtype entities. The
-- inheritance of the rep item chain ensures that SPARK-related pragmas
-- are not clobbered when the signed integer type acts as a full view of
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-10 3:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10 3:24 [gcc(refs/users/guojiufu/heads/personal-branch)] [Ada] Do not set the bounds of integer types to be universal Jiu Fu Guo
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).