]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix error message about limited extensions
authorRonan Desplanques <desplanques@adacore.com>
Tue, 16 Sep 2025 08:12:29 +0000 (10:12 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 29 Sep 2025 09:43:39 +0000 (11:43 +0200)
Consider the following package:

    package P is
       type T1 is tagged limited null record;

       type T2 is new T1 with private;
    private

       type T2 is limited new T1 with null record;
    end P;

It should be rejected because of ARM 7.3 (10.1/3). Before this patch,
GNAT did reject it, with the following error message:

    full view of non-limited extension cannot be limited

This message is not right because the partial view of T2 here *is*
limited even if it doesn't have an explicit limited keyword in its
declaration. This patch changes the error message to something that's a
better match for ARM 7.3 (10.1/3).

This patch also tweaks another related error message and substitutes
a mention of ARM 7.3 (10.1/3) for the Ada Issue it originated from in a
comment.

gcc/ada/ChangeLog:

* sem_ch3.adb (Process_Full_View): Fix error message.

gcc/ada/sem_ch3.adb

index c261305f286d326571c9f9dac35d9a04f392484c..9ca77089d1a366af74522e845cd1322d844629c8 100644 (file)
@@ -21993,7 +21993,7 @@ package body Sem_Ch3 is
          end if;
       end if;
 
-      --  AI-419: verify that the use of "limited" is consistent
+      --  RM 7.3 (10.1/3): verify that the use of "limited" is consistent
 
       declare
          Orig_Decl : constant Node_Id := Original_Node (N);
@@ -22009,7 +22009,9 @@ package body Sem_Ch3 is
               and then Limited_Present (Type_Definition (Orig_Decl))
             then
                Error_Msg_N
-                 ("full view of non-limited extension cannot be limited", N);
+                 ("full view of implicitly limited extension must be "
+                  & "implicitly limited",
+                  N);
 
             --  Conversely, if the partial view carries the limited keyword,
             --  the full view must as well, even if it may be redundant.
@@ -22018,7 +22020,8 @@ package body Sem_Ch3 is
               and then not Limited_Present (Type_Definition (Orig_Decl))
             then
                Error_Msg_N
-                 ("full view of limited extension must be explicitly limited",
+                 ("full view of explicitly limited extension must be "
+                  & "explicitly limited",
                   N);
             end if;
          end if;