public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Make Is_OK_Static_Subtype use Is_Static_Subtype
@ 2021-05-06  7:58 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-05-06  7:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ghjuvan Lacambre

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

The reason for this change is two-fold:
- There is code duplication between Is_OK_Static_Subtype and
  Is_Static_Subtype
- Is_Static_Subtype is more correct than Is_OK_Static_Subtype (e.g. the
  dynamic predicate checks are more complete in Is_Static_Subtype).

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

gcc/ada/

	* sem_eval.adb (Is_OK_Static_Subtype): Call Is_Static_Subtype,
	remove redundant checks.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1274 bytes --]

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
@@ -5549,23 +5549,16 @@ package body Sem_Eval is
          return False;
       end if;
 
-      Anc_Subt := Ancestor_Subtype (Typ);
-
-      if Anc_Subt = Empty then
-         Anc_Subt := Base_T;
-      end if;
+      --  Then, check if the subtype is strictly static. This takes care of
+      --  checking for generics and predicates.
 
-      if Is_Generic_Type (Root_Type (Base_T))
-        or else Is_Generic_Actual_Type (Base_T)
-      then
-         return False;
-
-      elsif Has_Dynamic_Predicate_Aspect (Typ) then
+      if not Is_Static_Subtype (Typ) then
          return False;
+      end if;
 
       --  String types
 
-      elsif Is_String_Type (Typ) then
+      if Is_String_Type (Typ) then
          return
            Ekind (Typ) = E_String_Literal_Subtype
              or else
@@ -5579,6 +5572,12 @@ package body Sem_Eval is
             return True;
 
          else
+            Anc_Subt := Ancestor_Subtype (Typ);
+
+            if No (Anc_Subt) then
+               Anc_Subt := Base_T;
+            end if;
+
             --  Scalar_Range (Typ) might be an N_Subtype_Indication, so use
             --  Get_Type_{Low,High}_Bound.
 



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-06  7:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06  7:58 [Ada] Make Is_OK_Static_Subtype use Is_Static_Subtype Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).