https://gcc.gnu.org/g:6ecabe33c179b6c02bc50028d8a95a0143f452d3

commit r17-1325-g6ecabe33c179b6c02bc50028d8a95a0143f452d3
Author: Mathias Aparicio <[email protected]>
Date:   Mon May 4 10:45:50 2026 +0200

    ada: Fix ICE on static predicate when all case alternatives are False
    
    Before this patch, creating a pragma predicate with the static keyword
    whose body included a case-expression where every alternative was
    statically evaluated to false leads to an ICE.
    
    When the case expression had all alternatives resolved to False,
    Build_Discrete_Static_Predicate.Get_Rlist returned an Empty list and
    later in the code Next was called on the Empty List.
    
    Now return false_range in this case.
    
    gcc/ada/ChangeLog:
    
            * sem_ch13.adb (Build_Discrete_Static_Predicate.Get_RList): If
            case expression alternatives are False return False_Range.

Diff:
---
 gcc/ada/sem_ch13.adb | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 722999da4594..47230c2f4d75 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -10167,6 +10167,9 @@ package body Sem_Ch13 is
                      Next (Alt);
                   end loop;
 
+                  if Is_Empty_List (Choices) then
+                     return False_Range;
+                  end if;
                   return Membership_Entries (First (Choices), Static);
                end;

Reply via email to