[Ada] Conformance of quantified expressions
Arnaud Charlet
charlet@adacore.com
Thu Jan 12 16:01:00 GMT 2017
This patch implements AI12-050, which extends the conformance rules to Ada2012
quantified expressions. Previously the conformance of corresponding identifiers
in the two expressions required that they denote the same entity. The loop
parameters of two quantified expressions are conformant if the identifiers are
the same, even though they denote different entities.
The following must compile quietly:
gcc -c quantified_expressions.adb
gcc -c -gnatc quantified_expressions.adb
---
with Support; use Support;
package Quantified_Expressions is
procedure Matrix_Processing
(M : in out Matrix;
B : Boolean := (for all I in Ind =>
(for some J in Ind =>
Sample_Matrix (I, J) = 0)));
end Quantified_Expressions;
---
package body Quantified_Expressions is
procedure Matrix_Processing
(M : in out Matrix;
B : Boolean := (for all I in Ind =>
(for some J in Ind =>
Sample_Matrix (I, J) = 0)))
is
begin
null;
end Matrix_Processing;
end Quantified_Expressions;
---
with Ada.Containers.Vectors;
package Support is
subtype Ind is Integer range 1 .. 10;
type Matrix is array (Ind, Ind) of Integer;
Sample_Matrix : Matrix;
end Support;
Tested on x86_64-pc-linux-gnu, committed on trunk
2017-01-12 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb (Fully_Conformant_Expressions): Handle properly
quantified expressions, following AI12-050: the loop parameters
of two quantified expressions are conformant if they have the
same identifier.
-------------- next part --------------
Index: sem_ch6.adb
===================================================================
--- sem_ch6.adb (revision 244352)
+++ sem_ch6.adb (working copy)
@@ -8476,10 +8476,22 @@
elsif Is_Entity_Name (E1) and then Is_Entity_Name (E2) then
if Present (Entity (E1)) then
return Entity (E1) = Entity (E2)
+
+ -- One may be a discriminant that has been replaced by
+ -- the correspondding discriminal
+
or else (Chars (Entity (E1)) = Chars (Entity (E2))
and then Ekind (Entity (E1)) = E_Discriminant
- and then Ekind (Entity (E2)) = E_In_Parameter);
+ and then Ekind (Entity (E2)) = E_In_Parameter)
+ -- AI12-050 : the loop variables of quantified expressions
+ -- match if the have the same identifier, even though they
+ -- are different entities.
+
+ or else (Chars (Entity (E1)) = Chars (Entity (E2))
+ and then Ekind (Entity (E1)) = E_Loop_Parameter
+ and then Ekind (Entity (E2)) = E_Loop_Parameter);
+
elsif Nkind (E1) = N_Expanded_Name
and then Nkind (E2) = N_Expanded_Name
and then Nkind (Selector_Name (E1)) = N_Character_Literal
More information about the Gcc-patches
mailing list