diff mbox series

[Ada] Detect protected types as program units

Message ID 20171009151908.GA113750@adacore.com
State New
Headers show
Series [Ada] Detect protected types as program units | expand

Commit Message

Pierre-Marie de Rodat Oct. 9, 2017, 3:19 p.m. UTC
Routine Unit_Declaration_Node now recognizes protected types as program
units and returns their declaration nodes; previously it returned
declaration nodes of the enclosing program units. This was an oversight.

------------
-- Source --
------------

--  illegal.ads

package Illegal
  with SPARK_Mode
is
   protected type PT
     with SPARK_Mode => Off
   is
   end PT;

end Illegal;

--  illegal.adb

package body Illegal
  with SPARK_Mode
is
   protected body PT
     with SPARK_Mode    --  Error
   is
   end PT;

end Illegal;

----------------------------
-- Compilation and output --
----------------------------

$ gcc -c illegal.adb 
illegal.adb:5:11: incorrect use of SPARK_Mode
illegal.adb:5:11: value Off was set for SPARK_Mode on "PT" at illegal.ads:5

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

2017-10-09  Piotr Trojanek  <trojanek@adacore.com>

	* sem_aux.adb (Unit_Declaration_Node): Detect protected declarations,
	just like other program units listed in Ada RM 10.1(1).
diff mbox series

Patch

Index: sem_aux.adb
===================================================================
--- sem_aux.adb	(revision 253546)
+++ sem_aux.adb	(working copy)
@@ -1693,6 +1693,7 @@ 
         and then Nkind (N) /= N_Package_Renaming_Declaration
         and then Nkind (N) /= N_Procedure_Instantiation
         and then Nkind (N) /= N_Protected_Body
+        and then Nkind (N) /= N_Protected_Type_Declaration
         and then Nkind (N) /= N_Subprogram_Declaration
         and then Nkind (N) /= N_Subprogram_Body
         and then Nkind (N) /= N_Subprogram_Body_Stub