diff mbox

[Ada] Spurious error on container "of" loop

Message ID 20160502092356.GA112614@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet May 2, 2016, 9:23 a.m. UTC
This patch modifies the implementation of container indexing to inspect the
base type of the container in case the container is a subtype. No
simple reproducer found.

Tested on x86_64-pc-linux-gnu, committed on trunk

2016-05-02  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_ch4.adb (Find_Indexing_Operations): Use the underlying type
	of the container base type in case the container is a subtype.
	* sem_ch5.adb (Analyze_Iterator_Specification): Ensure that
	the selector has an entity when checking for a component of a
	mutable object.
diff mbox

Patch

Index: sem_ch5.adb
===================================================================
--- sem_ch5.adb	(revision 235706)
+++ sem_ch5.adb	(working copy)
@@ -1817,7 +1817,7 @@ 
       Bas : Entity_Id;
       Typ : Entity_Id;
 
-   --   Start of processing for Analyze_iterator_Specification
+   --   Start of processing for Analyze_Iterator_Specification
 
    begin
       Enter_Name (Def_Id);
@@ -2207,6 +2207,8 @@ 
                      --  be performed.
 
                      if Nkind (Orig_Iter_Name) = N_Selected_Component
+                       and then
+                         Present (Entity (Selector_Name (Orig_Iter_Name)))
                        and then Ekind_In
                                   (Entity (Selector_Name (Orig_Iter_Name)),
                                    E_Component,
Index: sem_ch4.adb
===================================================================
--- sem_ch4.adb	(revision 235711)
+++ sem_ch4.adb	(working copy)
@@ -7619,12 +7619,14 @@ 
       begin
          Typ := T;
 
+         --  Use the specific type when the parameter type is class-wide
+
          if Is_Class_Wide_Type (Typ) then
             Typ := Root_Type (Typ);
          end if;
 
          Ref := Empty;
-         Typ := Underlying_Type (Typ);
+         Typ := Underlying_Type (Base_Type (Typ));
 
          Inspect_Primitives   (Typ, Ref);
          Inspect_Declarations (Typ, Ref);