This patch adds a check to reject an aspect Predicate on a formal type
declaration.
Compiling gen.adb must yield:
gen.ads:2:55: predicate cannot apply to formal type
---
generic
type T is array (Integer range <>) of Integer
with Predicate => T'First /= 1;
function Gen return Integer;
---
function Gen return Integer is
X : T(1 .. 2);
begin
return X'First;
end Gen;
Tested on x86_64-pc-linux-gnu, committed on trunk
2017-12-05 Ed Schonberg <[email protected]>
* sem_ch13.adb (Analyze_Aspect_Specifications, case Predicate): A
predicate cannot apply to a formal type.
Index: sem_ch13.adb
===================================================================
--- sem_ch13.adb (revision 255408)
+++ sem_ch13.adb (working copy)
@@ -2389,6 +2389,10 @@
elsif Is_Incomplete_Type (E) then
Error_Msg_N
("predicate cannot apply to incomplete view", Aspect);
+
+ elsif Is_Generic_Type (E) then
+ Error_Msg_N
+ ("predicate cannot apply to formal type", Aspect);
goto Continue;
end if;