aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch7.adb
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2018-05-21 14:50:23 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-05-21 14:50:23 +0000
commit689751d2f7ae12bd34637801860a766d1196d960 (patch)
tree3460244deb3d6eab3d867ef21c4e1f6e16d35dfc /gcc/ada/sem_ch7.adb
parent3ae9d95322f3859298b77a306f38e70dbcb34194 (diff)
downloadgcc-689751d2f7ae12bd34637801860a766d1196d960.zip
gcc-689751d2f7ae12bd34637801860a766d1196d960.tar.gz
gcc-689751d2f7ae12bd34637801860a766d1196d960.tar.bz2
[Ada] Only allow Has_Discriminants on type entities
This patch enforces what the comment for Has_Discriminant says: -- Has_Discriminants (Flag5) -- Defined in all types and subtypes. to avoid semantically undefined calls on non-type entities. It also adapts other routines to respect this comment. No user-visible impact. 2018-05-21 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * einfo.adb (Has_Discriminants): Stronger assertion. (Set_Has_Discriminants): Stronger assertion. * sem_ch13.adb (Push_Scope_And_Install_Discriminants): Adapt to respect the stronger assertion on Has_Discriminant. (Uninstall_Discriminants_And_Pop_Scope): Same as above. * sem_util.adb (New_Copy_Tree): Same as above. * sem_ch7.adb (Generate_Parent_References): Prevent calls to Has_Discriminant on non-type entities that might happen when the compiled code has errors. * sem_ch3.adb (Derived_Type_Declaration): Only call Set_Has_Discriminant on type entities. From-SVN: r260447
Diffstat (limited to 'gcc/ada/sem_ch7.adb')
-rw-r--r--gcc/ada/sem_ch7.adb5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb
index 41af7c9..9302f1a 100644
--- a/gcc/ada/sem_ch7.adb
+++ b/gcc/ada/sem_ch7.adb
@@ -1399,10 +1399,13 @@ package body Sem_Ch7 is
-- We are looking at an incomplete or private type declaration
-- with a known_discriminant_part whose full view is an
- -- Unchecked_Union.
+ -- Unchecked_Union. The seemingly useless check with Is_Type
+ -- prevents cascaded errors when routines defined only for type
+ -- entities are called with non-type entities.
if Nkind_In (Decl, N_Incomplete_Type_Declaration,
N_Private_Type_Declaration)
+ and then Is_Type (Defining_Identifier (Decl))
and then Has_Discriminants (Defining_Identifier (Decl))
and then Present (Full_View (Defining_Identifier (Decl)))
and then