[Ada] Ada2020: AI12-0198 potentially unevaluated components of arrays

Message ID 20200707092736.GA41554@adacore.com
State New
Headers show
Series
  • [Ada] Ada2020: AI12-0198 potentially unevaluated components of arrays
Related show

Commit Message

Pierre-Marie de Rodat July 7, 2020, 9:27 a.m.
This patch fixes a regression in the SPARK testsuite.

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

gcc/ada/

	* sem_util.adb (Is_Potentially_Unevaluated): Protect reading
	attribute Etype.

Patch

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -17805,6 +17805,8 @@  package body Sem_Util is
                                N_Or_Else,
                                N_Quantified_Expression)
         and then not (Nkind (Par) = N_Aggregate
+                        and then Present (Etype (Par))
+                        and then Etype (Par) /= Any_Composite
                         and then Is_Array_Type (Etype (Par)))
       loop
          Expr := Par;
@@ -17871,6 +17873,7 @@  package body Sem_Util is
                   return True;
 
                elsif Nkind (Choice) = N_Identifier
+                 and then Present (Etype (Choice))
                  and then Present (Scalar_Range (Etype (Choice)))
                  and then
                    Non_Static_Or_Null_Range (Scalar_Range (Etype (Choice)))