diff mbox

[Ada] Missing error on classwide precondition on a generic subprogram

Message ID 20160427124229.GA90388@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet April 27, 2016, 12:42 p.m. UTC
A generic subprogram is never a primitive operation, and thus a classwide
condition for it is not legal. This patch diagnoses such an illegal class-
wide condition properly.

Example in ACATS test B611003

Tested on x86_64-pc-linux-gnu, committed on trunk

2016-04-27  Ed Schonberg  <schonberg@adacore.com>

	* sem_prag.adb (Analyze_Pre_Post_Condition_In_Decl_Part):
	A generic subprogram is never a primitive operation, and thus
	a classwide condition for it is not legal.
diff mbox

Patch

Index: sem_prag.adb
===================================================================
--- sem_prag.adb	(revision 235481)
+++ sem_prag.adb	(working copy)
@@ -23319,11 +23319,12 @@ 
       if Class_Present (N) then
 
          --  Verify that a class-wide condition is legal, i.e. the operation is
-         --  a primitive of a tagged type.
+         --  a primitive of a tagged type. Note that a generic subprogram is
+         --  not a primitive operation.
 
          Disp_Typ := Find_Dispatching_Type (Spec_Id);
 
-         if No (Disp_Typ) then
+         if No (Disp_Typ) or else Is_Generic_Subprogram (Spec_Id) then
             Error_Msg_Name_1 := Original_Aspect_Pragma_Name (N);
 
             if From_Aspect_Specification (N) then