aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2018-05-21 14:51:30 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-05-21 14:51:30 +0000
commita2fcf1e02c7809a14e2bde3a26fec86b4cbd9ab3 (patch)
tree965e9eecd1c483c226fab310bb3af99a96c626a4
parent663afa9fac474647f69f242deab6bdc0bcaf1bf8 (diff)
downloadgcc-a2fcf1e02c7809a14e2bde3a26fec86b4cbd9ab3.zip
gcc-a2fcf1e02c7809a14e2bde3a26fec86b4cbd9ab3.tar.gz
gcc-a2fcf1e02c7809a14e2bde3a26fec86b4cbd9ab3.tar.bz2
[Ada] Clarify code for accessing full view of a type
2018-05-21 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * sem_eval.adb (Is_Null_Range): Clarify access to the full view of a type. (Not_Null_Range): Same as above. From-SVN: r260460
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/sem_eval.adb18
2 files changed, 16 insertions, 8 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 0720a9c..10661df 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2018-04-04 Piotr Trojanek <trojanek@adacore.com>
+
+ * sem_eval.adb (Is_Null_Range): Clarify access to the full view of a
+ type.
+ (Not_Null_Range): Same as above.
+
2018-04-04 Hristian Kirtchev <kirtchev@adacore.com>
* exp_ch3.adb: Minor reformatting.
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb
index ca51626..48e141d 100644
--- a/gcc/ada/sem_eval.adb
+++ b/gcc/ada/sem_eval.adb
@@ -4767,8 +4767,7 @@ package body Sem_Eval is
and then Compile_Time_Known_Value (Hi)
then
declare
- Typ : Entity_Id := Etype (Lo);
- Full_Typ : constant Entity_Id := Full_View (Typ);
+ Typ : Entity_Id := Etype (Lo);
begin
-- When called from the frontend, as part of the analysis of
-- potentially static expressions, Typ will be the full view of a
@@ -4777,8 +4776,10 @@ package body Sem_Eval is
-- is null, Typ might be a private type and we need to explicitly
-- switch to its corresponding full view to access the same info.
- if Present (Full_Typ) then
- Typ := Full_Typ;
+ if Is_Incomplete_Or_Private_Type (Typ)
+ and then Present (Full_View (Typ))
+ then
+ Typ := Full_View (Typ);
end if;
if Is_Discrete_Type (Typ) then
@@ -5356,8 +5357,7 @@ package body Sem_Eval is
and then Compile_Time_Known_Value (Hi)
then
declare
- Typ : Entity_Id := Etype (Lo);
- Full_Typ : constant Entity_Id := Full_View (Typ);
+ Typ : Entity_Id := Etype (Lo);
begin
-- When called from the frontend, as part of the analysis of
-- potentially static expressions, Typ will be the full view of a
@@ -5366,8 +5366,10 @@ package body Sem_Eval is
-- is null, Typ might be a private type and we need to explicitly
-- switch to its corresponding full view to access the same info.
- if Present (Full_Typ) then
- Typ := Full_Typ;
+ if Is_Incomplete_Or_Private_Type (Typ)
+ and then Present (Full_View (Typ))
+ then
+ Typ := Full_View (Typ);
end if;
if Is_Discrete_Type (Typ) then