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] Expression functions as completions and private types


An expression function that is a completion is a freeze point for all
entities referenced in its expression. As a consequence, a reference
to an uncompleted private type declared in an enclosing scope is illegal.
This patch adds the proper check to enforce this rule.

Compiling env_baselines.ads must yield:

   env_baseline.ads:16:51: premature use of private type "T"

---
package Env_Baseline is
   package Side is
      type T is (First, Last);
   end Side;

   type T is private;

   package General is
      type T is private;

      function First (Set : T) return Env_Baseline.T;

   private
      type T is array (Side.T) of Env_Baseline.T;

      function First (Set : T) return Env_Baseline.T is (Set (Side.First));
   end General;

private
   type T is record
      Major : Natural;
      Minor : Natural;
   end record;
end Env_Baseline;

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

2017-01-13  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch6.adb (Analyze_Expression_Function): If the expression
	function is a completion, all entities referenced in the
	expression are frozen. As a consequence, a reference to an
	uncompleted private type from an enclosing scope is illegal.

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]