[Ada] Do not perform useless work in Check_No_Parts_Violations
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 23 Feb 2021 11:50:25 +0000 (12:50 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 16 Jun 2021 08:42:59 +0000 (04:42 -0400)
gcc/ada/

* freeze.adb (Check_No_Parts_Violations): Return earlier if the
type is elementary or does not come from source.

gcc/ada/freeze.adb

index 91f1724..fd82169 100644 (file)
@@ -2584,27 +2584,30 @@ package body Freeze is
 
          --  Local declarations
 
-         Types_With_Aspect : Elist_Id :=
-           Get_Types_With_Aspect_In_Hierarchy (Typ);
-
-         Aspect_Value     : Entity_Id;
-         Curr_Value       : Entity_Id;
-         Curr_Typ_Elmt    : Elmt_Id;
-         Curr_Body_Elmt   : Elmt_Id;
-         Curr_Formal_Elmt : Elmt_Id;
-         Gen_Bodies       : Elist_Id;
-         Gen_Formals      : Elist_Id;
-         Scop             : Entity_Id;
+         Aspect_Value      : Entity_Id;
+         Curr_Value        : Entity_Id;
+         Curr_Typ_Elmt     : Elmt_Id;
+         Curr_Body_Elmt    : Elmt_Id;
+         Curr_Formal_Elmt  : Elmt_Id;
+         Gen_Bodies        : Elist_Id;
+         Gen_Formals       : Elist_Id;
+         Scop              : Entity_Id;
+         Types_With_Aspect : Elist_Id;
 
       --  Start of processing for Check_No_Parts_Violations
 
       begin
-         --  There are no types with No_Parts specified, so there
-         --  is nothing to check.
+         --  Nothing to check if the type is elementary or artificial
 
-         if Is_Empty_Elmt_List (Types_With_Aspect)
-           or else not Comes_From_Source (Typ)
-         then
+         if Is_Elementary_Type (Typ) or else not Comes_From_Source (Typ) then
+            return;
+         end if;
+
+         Types_With_Aspect := Get_Types_With_Aspect_In_Hierarchy (Typ);
+
+         --  Nothing to check if there are no types with No_Parts specified
+
+         if Is_Empty_Elmt_List (Types_With_Aspect) then
             return;
          end if;