https://gcc.gnu.org/g:fde2299c3affbaa278d47e2be6975445e5299982

commit r16-4050-gfde2299c3affbaa278d47e2be6975445e5299982
Author: Javier Miranda <[email protected]>
Date:   Tue Sep 2 12:15:45 2025 +0000

    ada: Spurious predicate check at default initialization
    
    For an object created by an object_declaration with no explicit
    initialization expression, if the type of the object is a record
    type (or a private record type) with no components and a dynamic
    predicate, then no predicate check must be performed at runtime
    (RM 3.2.4(31/5)).
    
    gcc/ada/ChangeLog:
    
            * sem_util.adb (Is_Partially_Initialized_Type): Return False
            for record types with no components.

Diff:
---
 gcc/ada/sem_util.adb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index ff2b23519375..e6c183c5f9c3 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -20240,7 +20240,12 @@ package body Sem_Util is
          elsif Is_Tagged_Type (Typ) then
             return True;
 
-         --  Case of nondiscriminated record
+         --  Case of record type with no components
+
+         elsif No (First_Component (Typ)) then
+            return False;
+
+         --  Case of record type with components
 
          else
             declare

Reply via email to