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]

[Ada] Fix glitch in static elab model


Tested on i686-linux, committed on trunk

This patch corrects an annoying glitch in the static elaboration model.
If a child unit accesses a function from a unit that is with'ed in an
ancestor, then the unit is not properly marked as elaboration all needed.

A test program is:

package P is
   function R return Integer;
end P;

with P;
package Q is end;

package Q.C is
   M : Integer := P.R;
end Q.C;

If package Q.C is compiled, the ali file should contain the line:

W p			p.adb			p.ali  AD

(this line was previously missing, leading to a possibly wrong order
of elaboration).

This patch also fixes an bug in Same_Elaboration_Scope. Some elaboration checks
warn against access-before-elaboration within a single compilation, for
example when a generic package is instantiated before its body has been
seen. Same_Elaboration_Scope determines whether the declaration of the
item and the reference are part of the same elaboration. For example,
if one of them is within a subprogram and the other is not, no test is
needed because its elaboration will take place during a call, and not
when the subprogram itself is elaborated. The routine therefore examines
the enclosing scopes and skips nested packages and blocks. The code
however failed to regard packages that are compilation units as separate
elaboration scopes. This leads to superfluous checks and in some cases
to spurious warnings about ABE that cannot occur.

2006-02-13  Ed Schonberg  <schonberg@adacore.com>
	    Robert Dewar  <dewar@adacore.com>

	* sem_elab.adb (Same_Elaboration_Scope): A package that is a
	compilation unit is an elaboration scope.
	(Add_Task_Proc): Add '\' in 2-line warning message.
	(Activate_All_Desirable): Deal with case of unit with'ed by parent

Attachment: difs.76
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]