[Ada] Extend compile-time evaluation in case statements to all objects
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 7 Dec 2020 15:54:06 +0000 (16:54 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 28 Apr 2021 09:37:58 +0000 (05:37 -0400)
gcc/ada/

* sem_ch5.adb (Analyze_Case_Statement): Extend optimization to
all objects; fix typo in comment.

gcc/ada/sem_ch5.adb

index 04fc980..0869bea 100644 (file)
@@ -1456,7 +1456,7 @@ package body Sem_Ch5 is
          if Is_Entity_Name (Exp) then
             Ent := Entity (Exp);
 
-            if Is_Assignable (Ent) then
+            if Is_Object (Ent) then
                if List_Length (Choices) = 1
                  and then Nkind (First (Choices)) in N_Subexpr
                  and then Compile_Time_Known_Value (First (Choices))
@@ -1475,7 +1475,7 @@ package body Sem_Ch5 is
             end if;
          end if;
 
-         --  Case where expression is not an entity name of a variable
+         --  Case where expression is not an entity name of an object
 
          Analyze_Statements (Statements (Alternative));
       end Process_Statements;