Before this patch, GNAT would ignore dynamic predicates specified
through the "predicate" pragma when attempting to evaluate expressions.
This would result in incorrect behavior in cases like the following:
subtype SS is String (1 .. 4) with Predicate => SS (2) = 'e';
pragma Assert ("aaaa" in SS);
Where the assert would not fail.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_eval.adb (Is_Static_Subtype): Take predicates created
through "predicate" pragma into account.
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb
--- a/gcc/ada/sem_eval.adb
+++ b/gcc/ada/sem_eval.adb
@@ -5741,6 +5741,8 @@ package body Sem_Eval is
elsif Has_Dynamic_Predicate_Aspect (Typ)
or else (Is_Derived_Type (Typ)
and then Has_Aspect (Typ, Aspect_Dynamic_Predicate))
+ or else (Has_Aspect (Typ, Aspect_Predicate)
+ and then not Has_Static_Predicate (Typ))
then
return False;