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] Visibility in expression functions


If the expression function is not a completion, the usage names in the 
expression must be determined at the point of declaration, even though the
generated body is inserted at the end of the current declaration list or
package to prevent early freezing.

The following must be rejected with:

    forward_reference.ads:2:35: "F2" is undefined

---
package Forward_Reference is
   function F1 return Boolean is (F2);    --  Error: forward reference
   function F2 return Boolean is (True);
end Forward_Reference;

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

2011-12-12  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch6.adb (Analyze_Expression_Function): If the function
	is not a completion, pre-analyze the expression now to prevent
	spurious visibility on later entities. The body is inserted at
	the end of the current declaration list or package to prevent
	early freezing, but the visibility is established at the point
	of definition.

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]