As GNATprove uses the AST after semantic analysis without expansion, the
recent optimization in the evaluation of selected components for
aggregates was leading to incorrect AST where possible run-time errors
in the evaluation of the (aggregate) prefix were not taken into account.
Fixed by only enabling the change for compile time known aggregates.

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

gcc/ada/

        * sem_eval.adb (Eval_Selected_Component): Only consider compile
        time known aggregates.
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb
--- a/gcc/ada/sem_eval.adb
+++ b/gcc/ada/sem_eval.adb
@@ -3849,7 +3849,9 @@ package body Sem_Eval is
 
          Node := Unqualify (Prefix (N));
 
-         if Nkind (Node) = N_Aggregate then
+         if Nkind (Node) = N_Aggregate
+           and then Compile_Time_Known_Aggregate (Node)
+         then
             Comp := First (Component_Associations (Node));
             Nam  := Chars (Selector_Name (N));
 


Reply via email to