diff mbox series

[COMMITTED,07/35] ada: Tune detection of unconstrained and tagged items in Depends contract

Message ID 20240517083207.130391-7-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/35] ada: Add support for 'Object_Size to pragma Compile_Time_{Warning, Error} | expand

Commit Message

Marc Poulhiès May 17, 2024, 8:31 a.m. UTC
From: Piotr Trojanek <trojanek@adacore.com>

The Tagged/Array/Record/Private types are mutually exclusive, so they
can be examined like with a case statement (except for records with
private extensions, but their handling is not affected by this change).

gcc/ada/

	* sem_prag.adb (Is_Unconstrained_Or_Tagged_Item): Tune repeated
	testing of type kinds.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_prag.adb | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 2fc46ab0cd2..9dc22e3edc1 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -32970,14 +32970,14 @@  package body Sem_Prag is
       if Is_Tagged_Type (Typ) then
          return True;
 
-      elsif Is_Array_Type (Typ) and then not Is_Constrained (Typ) then
-         return True;
+      elsif Is_Array_Type (Typ) then
+         return not Is_Constrained (Typ);
 
       elsif Is_Record_Type (Typ) then
          return Has_Discriminants (Typ) and then not Is_Constrained (Typ);
 
-      elsif Is_Private_Type (Typ) and then Has_Discriminants (Typ) then
-         return True;
+      elsif Is_Private_Type (Typ) then
+         return Has_Discriminants (Typ);
 
       else
          return False;