aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/einfo-utils.adb
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2021-08-29 11:25:08 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2021-10-04 08:45:07 +0000
commitc36774bcc38ba51fc9091d92a079e5b2d4aab759 (patch)
treeba9ec3c09b1aa05ba21648c5e9edf42bfd43f9a0 /gcc/ada/einfo-utils.adb
parentf9974930bcb21fb436217972db38d04ab88eb8c4 (diff)
downloadgcc-c36774bcc38ba51fc9091d92a079e5b2d4aab759.zip
gcc-c36774bcc38ba51fc9091d92a079e5b2d4aab759.tar.gz
gcc-c36774bcc38ba51fc9091d92a079e5b2d4aab759.tar.bz2
[Ada] Declaration_Node for Itypes returns Empty or declaration
gcc/ada/ * einfo.ads (Declaration_Node): Document that Declaration_Node for Itypes. * einfo-utils.adb (Declaration_Node): Make it return Empty for Itypes, or a proper type or subtype declaration. * gen_il-gen.adb: Minor comment improvement.
Diffstat (limited to 'gcc/ada/einfo-utils.adb')
-rw-r--r--gcc/ada/einfo-utils.adb21
1 files changed, 13 insertions, 8 deletions
diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb
index 38cfe34..0274e6b 100644
--- a/gcc/ada/einfo-utils.adb
+++ b/gcc/ada/einfo-utils.adb
@@ -655,16 +655,21 @@ package body Einfo.Utils is
P := Parent (Id);
end if;
+ while Nkind (P) in N_Selected_Component | N_Expanded_Name
+ or else (Nkind (P) = N_Defining_Program_Unit_Name
+ and then Is_Child_Unit (Id))
loop
- if Nkind (P) in N_Selected_Component | N_Expanded_Name
- or else (Nkind (P) = N_Defining_Program_Unit_Name
- and then Is_Child_Unit (Id))
- then
- P := Parent (P);
- else
- return P;
- end if;
+ P := Parent (P);
end loop;
+
+ if Is_Itype (Id)
+ and then Nkind (P) not in
+ N_Full_Type_Declaration | N_Subtype_Declaration
+ then
+ P := Empty;
+ end if;
+
+ return P;
end Declaration_Node;
---------------------