]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Report error in non-legal class-wide conditions
authorJavier Miranda <miranda@adacore.com>
Mon, 15 Aug 2022 18:31:50 +0000 (18:31 +0000)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 6 Sep 2022 07:14:22 +0000 (09:14 +0200)
gcc/ada/

* sem_prag.adb
(Analyze_Pre_Post_Condition_In_Decl_Part): Improve check to report
an error in non-legal class-wide conditions.

gcc/ada/sem_prag.adb

index eaaf3d711798a274d33bd72857dc54497a29f690..13cee597d1a8cc3da60f4ba9fd00606187569473 100644 (file)
@@ -26138,12 +26138,9 @@ package body Sem_Prag is
       if Class_Present (N) then
 
          --  Verify that a class-wide condition is legal, i.e. the operation is
-         --  a primitive of a tagged type. Note that a generic subprogram is
-         --  not a primitive operation.
+         --  a primitive of a tagged type.
 
-         Disp_Typ := Find_Dispatching_Type (Spec_Id);
-
-         if No (Disp_Typ) or else Is_Generic_Subprogram (Spec_Id) then
+         if not Is_Dispatching_Operation (Spec_Id) then
             Error_Msg_Name_1 := Original_Aspect_Pragma_Name (N);
 
             if From_Aspect_Specification (N) then
@@ -26162,6 +26159,7 @@ package body Sem_Prag is
          --  Remaining semantic checks require a full tree traversal
 
          else
+            Disp_Typ := Find_Dispatching_Type (Spec_Id);
             Check_Class_Wide_Condition (Expr);
          end if;