]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix crash on array component with Default_Value
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 27 Sep 2021 14:15:39 +0000 (16:15 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 11 Oct 2021 13:38:09 +0000 (13:38 +0000)
gcc/ada/

* exp_util.adb (Inside_Init_Proc): Simplify.
* sem_aggr.adb (Resolve_Record_Aggregate): Fix style.
* sem_util.adb (Compile_Time_Constraint_Error): Guard against
calling Corresponding_Concurrent_Type with an array type entity.

gcc/ada/exp_util.adb
gcc/ada/sem_aggr.adb
gcc/ada/sem_util.adb

index cb180967d67fe70a74cfecc73b52876560bd536b..11499e155fc02b7ad25ad30ac2d5979a1b2857d4 100644 (file)
@@ -7994,10 +7994,8 @@ package body Exp_Util is
    ----------------------
 
    function Inside_Init_Proc return Boolean is
-      Proc : constant Entity_Id := Enclosing_Init_Proc;
-
    begin
-      return Proc /= Empty;
+      return Present (Enclosing_Init_Proc);
    end Inside_Init_Proc;
 
    ----------------------
index 9ae5ff616179f354f3f3e74b441bec1f54974322..b51a3d0c17b5a1862ad7b24fa63f93d28412de11 100644 (file)
@@ -5307,8 +5307,8 @@ package body Sem_Aggr is
 
                   Add_Association
                    (Component      => Component,
-                    Expr       => Empty,
-                    Assoc_List => New_Assoc_List,
+                    Expr           => Empty,
+                    Assoc_List     => New_Assoc_List,
                     Is_Box_Present => True);
 
                elsif Present (Parent (Component))
index b5f3d4cce034b6536e57168551b09fa78ffa404b..20e4395e4f3c440757605d8966896d2977ac741e 100644 (file)
@@ -6589,11 +6589,16 @@ package body Sem_Util is
 
                if Inside_Init_Proc then
                   declare
+                     Init_Proc_Type : constant Entity_Id :=
+                       Entity (Parameter_Type (First
+                                 (Parameter_Specifications
+                                    (Parent (Current_Scope_No_Loops)))));
+
                      Conc_Typ : constant Entity_Id :=
-                                  Corresponding_Concurrent_Type
-                                    (Entity (Parameter_Type (First
-                                      (Parameter_Specifications
-                                        (Parent (Current_Scope))))));
+                       (if Present (Init_Proc_Type)
+                          and then Init_Proc_Type in E_Record_Type_Id
+                        then Corresponding_Concurrent_Type (Init_Proc_Type)
+                        else Empty);
 
                   begin
                      --  Don't complain if the corresponding concurrent type