aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-10-28 04:55:16 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-11-26 03:40:02 -0500
commit678e19545eb22d3661d83641884f88fa5038a088 (patch)
tree8e03651011de97c866ef7c427883ec6f4c9f28f5 /gcc
parent8d87bb8f56db177718bf0f07df462b85a90c1ef3 (diff)
downloadgcc-678e19545eb22d3661d83641884f88fa5038a088.zip
gcc-678e19545eb22d3661d83641884f88fa5038a088.tar.gz
gcc-678e19545eb22d3661d83641884f88fa5038a088.tar.bz2
[Ada] Ada 2020 AI12-0401 Renaming of qualified expression of variable
gcc/ada/ * sem_ch8.adb (Analyze_Object_Renaming): Check for AI12-0401.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch8.adb16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index 4c80e024..f78d31a 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -1038,6 +1038,22 @@ package body Sem_Ch8 is
Mark_Ghost_Renaming (N, Entity (Nam));
end if;
+ -- Check against AI12-0401 here before Resolve may rewrite Nam and
+ -- potentially generate spurious warnings.
+
+ if Nkind (Nam) = N_Qualified_Expression
+ and then Is_Variable (Expression (Nam))
+ and then not
+ (Subtypes_Statically_Match (T, Etype (Expression (Nam)))
+ or else
+ Subtypes_Statically_Match (Base_Type (T), Etype (Nam)))
+ then
+ Error_Msg_N
+ ("subtype of renamed qualified expression does not " &
+ "statically match", N);
+ return;
+ end if;
+
Resolve (Nam, T);
-- If the renamed object is a function call of a limited type,