diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2012-05-15 11:37:57 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2012-05-15 11:37:57 +0200 |
commit | bb9c600b570e96332a06075f74affc3f51abe393 (patch) | |
tree | 0bf23f114d97e5a8f1413d50d35b32ce8ee4119f /gcc/ada/sem_eval.adb | |
parent | c4c768ddedd306d53d4b32166816c974c14e0f61 (diff) | |
download | gcc-bb9c600b570e96332a06075f74affc3f51abe393.zip gcc-bb9c600b570e96332a06075f74affc3f51abe393.tar.gz gcc-bb9c600b570e96332a06075f74affc3f51abe393.tar.bz2 |
[multiple changes]
2012-05-15 Ed Schonberg <schonberg@adacore.com>
* sem_eval.adb (Subtypes_Statically_Match): In Ada 2012, static
matching requires matching of static subtype predicates as well.
2012-05-15 Ed Schonberg <schonberg@adacore.com>
* sem_case.adb (Analyze_Choices): If the subtype of the
expression has a non-static predicate, the case alternatives
must cover the base type.
2012-05-15 Tristan Gingold <gingold@adacore.com>
* a-calend-vms.ads: Add pragma export to Split and Time_Of.
Merge comments from a-calend.ads to minimize differences.
2012-05-15 Sergey Rybin <rybin@adacore.com frybin>
* gnat_ugn.texi: gnatmetric: add a small example that demonstrates
the difference between control coupling and unit coupling.
2012-05-15 Tristan Gingold <gingold@adacore.com>
* bindgen.adb (Gen_Header): Remove code to emit LE_Set.
(Gen_Finalize_Library): Replace test with
a call to __gnat_reraise_library_exception_if_any.
* s-soflin.ads (Library_Exception): Do not export.
(Library_Exception_Set): Likewise.
* a-except-2005.ads, a-except-2005.adb
(Reraise_Library_Exception_If_Any): New procedure.
From-SVN: r187509
Diffstat (limited to 'gcc/ada/sem_eval.adb')
-rw-r--r-- | gcc/ada/sem_eval.adb | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index 0daeb4c..329a267 100644 --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -4664,6 +4664,41 @@ package body Sem_Eval is -- values match (RM 4.9.1(1)). function Subtypes_Statically_Match (T1, T2 : Entity_Id) return Boolean is + + function Predicates_Match return Boolean; + -- In Ada 2012, subtypes statically match if their static predicates + -- match as well. + + function Predicates_Match return Boolean is + Pred1 : Node_Id; + Pred2 : Node_Id; + + begin + if Ada_Version < Ada_2012 then + return True; + + elsif Has_Predicates (T1) /= Has_Predicates (T2) then + return False; + + else + Pred1 := Get_Rep_Item_For_Entity (T1, Name_Static_Predicate); + Pred2 := Get_Rep_Item_For_Entity (T2, Name_Static_Predicate); + + -- Subtypes statically match if the predicate comes from the + -- same declaration, which can only happen if one is a subtype + -- of the other and has no explicit predicate. + + -- Suppress warnings on order of actuals, which is otherwise + -- triggered by one of the two calls below. + + pragma Warnings (Off); + return Pred1 = Pred2 + or else (No (Pred1) and then Is_Subtype_Of (T1, T2)) + or else (No (Pred2) and then Is_Subtype_Of (T2, T1)); + pragma Warnings (On); + end if; + end Predicates_Match; + begin -- A type always statically matches itself @@ -4736,7 +4771,7 @@ package body Sem_Eval is -- If the bounds are the same tree node, then match if LB1 = LB2 and then HB1 = HB2 then - return True; + return Predicates_Match; -- Otherwise bounds must be static and identical value |