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] |
Tested on i686-linux, committed on trunk. If both spec and body of a unit have a with_clause on the same unit P, then the clause in the context of the body may be redundant, unless the context of the body includes another clause that mentions P, such as a pragma or a use clause. The code that checks for a subsequent clause that mentions P did not include a use clause on a package nested within P itself. The following must compile quietly: -- gcc -c -gnatwa calling.adb -- with Included; package Calling is procedure Modify_Cuicui_And_Print (Cuicui : Included.Nested.Nested_Kind_T); end Calling; with Included; use Included.Nested; package body Calling is procedure Modify_Cuicui_And_Print (Cuicui : Included.Nested.Nested_Kind_T) is String_Cuicui : constant String := Image (Nested_Kind_T'Succ (Cuicui)); pragma Unreferenced (String_Cuicui); begin null; end Modify_Cuicui_And_Print; end Calling; -- package Included is type Kind_T is (A, B); function Successor_Name (Element : Kind_T) return String; -- package Nested is type Nested_Kind_T is (Nested_A, Nested_B); function Image (Element : Nested_Kind_T) return String; end Nested; end Included; -- package body Included is function Successor_Name (Element : Kind_T) return String is pragma Unreferenced (Element); begin return "a"; end Successor_Name; -- package body Nested is function Image (Element : Nested_Kind_T) return String is pragma Unreferenced (Element); begin return "B"; end Image; end Nested; end Included; Similarly, if a child package spec P.T has a with_clause on a descendant of a sibling, such as P.Q.R.S, then the child unit Q is immediately visible in the body of P.T. This patch makes the processing of such with_clauses fully general (previously it only examined a fixed number of descendants). -- The following must compile quietly. -- package P is end; -- package P.Q is end; -- package P.Q.R is end; -- package P.Q.R.S is subtype Int is Integer; end; -- with P.Q.R.S; package P.T is function F (X : Integer) return P.Q.R.S.Int; end; -- package body P.T is function F (X : Integer) return P.Q.R.S.Int is begin return Q.R.S.Int (X); end; end; Finally, after compiling a subunit we must remove the context of the proper body to restore the context of the parent. If the subunit includes s with_clause on a sibling of some ancestor, the removal of the context might make an ancestor child unit not-visible, and its proper visibility must be restored explicitly. The problem only shows up when the subunit appears within a grand-child, it mentions a separate grand-child, and the enclosing body makes a reference to the enclosing child. par-c1-c2.adb must compile quietly: -- package Par is end; -- package par.c1 is x : integer; end par.c1; -- package par.c1.c2 is pragma Elaborate_Body; end; -- package par.c1.c3 is private end; -- with par.c1.c3; separate (par.c1.c2) package body sep is begin null; end; -- package body par.c1.c2 is package Sep is private end; package body Sep is separate; Thing : integer := par.c1.x; end; 2006-10-31 Ed Schonberg <schonberg@adacore.com> * sem_ch10.ads, sem_ch10.adb (Check_Redundant_Withs, Process_Body_Clauses): If the context of a body includes a use clause for P.Q then a with_clause for P in the same body is not redundant, even if the spec also has a with_clause on P. Add missing continuation mark to error msg (Build_Limited_Views): A limited view of a type is tagged if its declaration includes a record extension. (Analyze_Proper_Body): Set Corresponding_Stub field in N_Subunit node, even if the subunit has errors. This avoids malfunction by Lib.Check_Same_Extended_Unit in the presence of syntax errors. (Analyze_Compilation_Unit): Add circuit to make sure we get proper generation of obsolescent messages for with statements (cannot do this too early, or we cannot implement avoiding the messages in the case of obsolescent units withing obsolescent units). (Install_Siblings): If the with_clause is on a remote descendant of an ancestor of the current compilation unit, find whether there is a sibling child unit that is immediately visible. (Remove_Private_With_Clauses): New procedure, invoked after completing the analysis of the private part of a nested package, to remove from visibility the private with_clauses of the enclosing package declaration. (Analyze_With_Clause): Remove Check_Obsolescent call, this checking is now centralized in Generate_Reference. (Install_Limited_Context_Clauses): Remove superfluous error message associated with unlimited view visible through use and renamings. In addition, at the point in which the error is reported, we add the backslash to the text of the error to ensure that it is reported as a single error message. Use new // insertion for some continuation messages (Expand_Limited_With_Clause): Use copy of name rather than name itself, to create implicit with_clause for parent unit mentioned in original limited_with_clause. (Install_Limited_With_Unit): Set entity of parent identifiers if the unit is a child unit. For ASIS queries. (Analyze_Subunit): If the subunit appears within a child unit, make all ancestor child units directly visible again.
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] |