diff mbox series

[COMMITTED,05/16] ada: Minor tweaks to processing of Aggregate aspect

Message ID 20240614073633.2089692-5-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/16] ada: Remove unused name of aspect from Snames | expand

Commit Message

Marc Poulhiès June 14, 2024, 7:36 a.m. UTC
From: Eric Botcazou <ebotcazou@adacore.com>

The main one is to give the error for Aggregate applied to array types from
Analyze_Aspects_At_Freeze_Point instead of Check_Aspect_At_Freeze_Point, as
for the other aspects.  The message is also changed to be more direct.

gcc/ada/

	* aspects.ads (Operational_Aspect): Alphabetize.
	* sem_ch13.ads (Analyze_Aspects_At_Freeze_Point): Fix description.
	* sem_ch13.adb (Analyze_Aspects_At_Freeze_Point) <Aggregate>: Give
	the error for array types here instead of...
	(Analyze_Aspect_Specifications) <Aggregate>: Adjust comment.
	(Check_Aspect_At_Freeze_Point) <Aggregate>: ...here.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/aspects.ads  |  4 ++--
 gcc/ada/sem_ch13.adb | 17 ++++++++---------
 gcc/ada/sem_ch13.ads |  9 +++++----
 3 files changed, 15 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/aspects.ads b/gcc/ada/aspects.ads
index 3cc62de3411..1acbec87824 100644
--- a/gcc/ada/aspects.ads
+++ b/gcc/ada/aspects.ads
@@ -325,12 +325,12 @@  package Aspects is
    --  List is currently incomplete ???
 
    Operational_Aspect : constant array (Aspect_Id) of Boolean :=
-     (Aspect_Constant_Indexing          => True,
+     (Aspect_Aggregate                  => True,
+      Aspect_Constant_Indexing          => True,
       Aspect_Default_Iterator           => True,
       Aspect_Iterator_Element           => True,
       Aspect_Iterable                   => True,
       Aspect_Variable_Indexing          => True,
-      Aspect_Aggregate                  => True,
       others                            => False);
 
    --  The following array indicates aspects for which multiple occurrences of
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 46a359fd7d6..caebe2e793e 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -1367,7 +1367,11 @@  package body Sem_Ch13 is
                      Validate_Storage_Model_Type_Aspect (E, ASN);
 
                   when Aspect_Aggregate =>
-                     null;
+                     if Is_Array_Type (E) then
+                        Error_Msg_N
+                          ("aspect Aggregate may not be applied to array type",
+                           ASN);
+                     end if;
 
                   when others =>
                      null;
@@ -1384,7 +1388,7 @@  package body Sem_Ch13 is
          Next_Rep_Item (ASN);
       end loop;
 
-      --  Make a second pass for a Full_Access_Only entry
+      --  Make a second pass for a Full_Access_Only entry, see above why
 
       ASN := First_Rep_Item (E);
       while Present (ASN) loop
@@ -4130,8 +4134,8 @@  package body Sem_Ch13 is
                   end if;
 
                when Aspect_Aggregate =>
-                  --  We will be checking that the aspect is not specified on a
-                  --  non-array type in Check_Aspect_At_Freeze_Point
+                  --  We will be checking that the aspect is not specified on
+                  --  an array type in Analyze_Aspects_At_Freeze_Point.
 
                   Validate_Aspect_Aggregate (Expr);
 
@@ -11378,11 +11382,6 @@  package body Sem_Ch13 is
             return;
 
          when Aspect_Aggregate =>
-            if Is_Array_Type (Entity (ASN)) then
-               Error_Msg_N
-                 ("aspect& can only be applied to non-array type",
-                  Ident);
-            end if;
             Resolve_Aspect_Aggregate (Entity (ASN), Expression (ASN));
             return;
 
diff --git a/gcc/ada/sem_ch13.ads b/gcc/ada/sem_ch13.ads
index 2bdca957826..aeacda833d1 100644
--- a/gcc/ada/sem_ch13.ads
+++ b/gcc/ada/sem_ch13.ads
@@ -312,10 +312,11 @@  package Sem_Ch13 is
    --  Quite an awkward approach, but this is an awkard requirement
 
    procedure Analyze_Aspects_At_Freeze_Point (E : Entity_Id);
-   --  Analyzes all the delayed aspects for entity E at freezing point. This
-   --  includes dealing with inheriting delayed aspects from the parent type
-   --  in the case where a derived type is frozen. Callers should check that
-   --  Has_Delayed_Aspects (E) is True before calling this routine.
+   --  Analyzes all the delayed aspects for entity E at the freeze point. Note
+   --  that this does not include dealing with inheriting delayed aspects from
+   --  the parent or base type in the case where a derived type or a subtype is
+   --  frozen. Callers should check that Has_Delayed_Aspects (E) is True before
+   --  calling this routine.
 
    procedure Check_Aspects_At_End_Of_Declarations (E : Entity_Id);
    --  Performs the processing described above at the freeze all point, and