diff mbox

[Ada] Spurious error with predicate on type derived from unconstrained array

Message ID 20160622095154.GA117806@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet June 22, 2016, 9:51 a.m. UTC
This patch fixes a spurious error on the compilation of a subprogram whose
formal parameter is derived from an unconstrained array type with a dynamic
predicate aspect.

The following must compile quietly:

   gcc -c gpr2-attribute.adb
   gcc -c -gnata gpr2-attribute.adb

---
package GPR2 is

   subtype Name_Type is String
     with Dynamic_Predicate => Name_Type'Length > 0;
end GPR2;
---
package GPR2.Attribute is

   type Qualified_Name (<>) is private;

   procedure Get (Q_Name : Qualified_Name);

private

   type Qualified_Name is new Name_Type;

end GPR2.Attribute;
--
package body GPR2.Attribute is

   procedure Get (Q_Name : Qualified_Name) is
      N : Name_Type := Name_Type (Q_Name);
   begin
      null;
   end Get;

end GPR2.Attribute;

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

2016-06-22  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch6.adb (Set_Actual_Subtypes): If the type of the actual
	has predicates, the actual subtype must be frozen properly
	because of the generated tests that may follow.  The predicate
	may be specified by an explicit aspect, or may be inherited in
	a derivation.
diff mbox

Patch

Index: sem_ch6.adb
===================================================================
--- sem_ch6.adb	(revision 237680)
+++ sem_ch6.adb	(working copy)
@@ -11308,9 +11308,10 @@ 
                  Freeze_Entity (Defining_Identifier (Decl), N));
 
             --  Ditto if the type has a dynamic predicate, because the
-            --  generated function will mention the actual subtype.
+            --  generated function will mention the actual subtype. The
+            --  predicate may come from an explicit aspect of be inherited.
 
-            elsif Has_Dynamic_Predicate_Aspect (T) then
+            elsif Has_Predicates (T) then
                Insert_List_Before_And_Analyze (Decl,
                  Freeze_Entity (Defining_Identifier (Decl), N));
             end if;