This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch adds machinery to catch illegal object or state declarations that introduce a hidden state within a package subject to a null abstract state. ------------ -- Source -- ------------ -- gen.ads generic type Data_Type is private; package Gen is Visible_Obj : Data_Type; private Private_Obj : Data_Type; end Gen; -- semantics.ads with Gen; package Semantics with Abstract_State => null is pragma Elaborate_Body; OK_1 : Integer; -- in visible declarations package Visible_Instance is new Gen (Integer); -- Visible_Obj is ok -- Private_Obj is an error package Visible_Nested with Abstract_State => Error_1 -- introduces state is OK_2 : Integer; -- in visible declarations of a visible package private Error_2 : Integer; -- in private part regardless of visibility end Visible_Nested; private Error_3 : Integer; -- in private part package Private_Instance is new Gen (Integer); -- Visible_Obj is an error -- Private_Obj is an error package Private_Nested with Abstract_State => Error_4 -- introduces state is Error_5 : Integer; -- in visible declarations but in private part private Error_6 : Integer; -- in private part end Private_Nested; end Semantics; -- semantics.adb package body Semantics is Error_7 : Integer; -- in body package Body_Instance is new Gen (Integer); -- Visible_Obj is an error -- Private_Obj is an error package Body_Nested with Abstract_State => Error_8 -- introduces state is Error_9 : Integer; -- in visible declarations but in body procedure Proc; private Error_10 : Integer; -- in private part end Body_Nested; package body Body_Nested is Error_11 : Integer; -- in body procedure Proc is OK_3 : Integer; -- nested in subprogram package Proc_Instance is new Gen (Integer); -- Visible_Obj is ok -- Private_Obj is ok package Proc_Nested with Abstract_State => OK_4 -- nested in subprogram is OK_5 : Integer; -- nested in subprogram private OK_6 : Integer; -- nested in subprogram end Proc_Nested; begin null; end Proc; end Body_Nested; end Semantics; ---------------------------- -- Compilation and output -- ---------------------------- $ gcc -c -gnat12 -gnatd.V semantics.adb semantics.adb:2:04: cannot introduce hidden state "Error_7" semantics.adb:2:04: package "Semantics" has null abstract state semantics.adb:4:04: instantiation error at gen.ads:5 semantics.adb:4:04: cannot introduce hidden state "Visible_Obj" semantics.adb:4:04: package "Semantics" has null abstract state semantics.adb:4:04: instantiation error at gen.ads:8 semantics.adb:4:04: cannot introduce hidden state "Private_Obj" semantics.adb:4:04: package "Semantics" has null abstract state semantics.adb:9:29: cannot introduce hidden state "Error_8" semantics.adb:9:29: package "Semantics" has null abstract state semantics.adb:11:07: cannot introduce hidden state "Error_9" semantics.adb:11:07: package "Semantics" has null abstract state semantics.adb:14:07: cannot introduce hidden state "Error_10" semantics.adb:14:07: package "Semantics" has null abstract state semantics.adb:18:07: cannot introduce hidden state "Error_11" semantics.adb:18:07: package "Semantics" has null abstract state semantics.ads:10:04: instantiation error at gen.ads:8 semantics.ads:10:04: cannot introduce hidden state "Private_Obj" semantics.ads:10:04: package "Semantics" has null abstract state semantics.ads:15:30: cannot introduce hidden state "Error_1" semantics.ads:15:30: package "Semantics" has null abstract state semantics.ads:19:07: cannot introduce hidden state "Error_2" semantics.ads:19:07: package "Semantics" has null abstract state semantics.ads:23:04: cannot introduce hidden state "Error_3" semantics.ads:23:04: package "Semantics" has null abstract state semantics.ads:25:04: instantiation error at gen.ads:5 semantics.ads:25:04: cannot introduce hidden state "Visible_Obj" semantics.ads:25:04: package "Semantics" has null abstract state semantics.ads:25:04: instantiation error at gen.ads:8 semantics.ads:25:04: cannot introduce hidden state "Private_Obj" semantics.ads:25:04: package "Semantics" has null abstract state semantics.ads:30:30: cannot introduce hidden state "Error_4" semantics.ads:30:30: package "Semantics" has null abstract state semantics.ads:32:07: cannot introduce hidden state "Error_5" semantics.ads:32:07: package "Semantics" has null abstract state semantics.ads:34:07: cannot introduce hidden state "Error_6" semantics.ads:34:07: package "Semantics" has null abstract state Tested on x86_64-pc-linux-gnu, committed on trunk 2013-04-25 Hristian Kirtchev <kirtchev@adacore.com> * einfo.adb (Abstract_States): The attribute now applies to generic packages. * sem_ch3.adb (Analyze_Object_Declaration): Check whether an object declaration introduces an illegal hidden state. * sem_prag.adb (Analyze_Abstract_State): Check whether a state declaration introduces an illegal hidden state. * sem_util.ads, sem_util.adb (Check_No_Hidden_State): New routine.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |