This is the mail archive of the 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] Freezing issues with expression functions

An expression function does not freeze the corresponding expression. The
function and the expression are frozen by a call, or by the end of the
enclosing declarative part. If the expression includes attribute references
to outer types, these must be frozen at that point. This patch ensures that
freeze nodes for such types are generated properly.

Executing the following::
   gnatmake -q bad_main.adb

must yield:

   bad main OK

with Text_IO; use Text_IO;
with Bad_Gen;
procedure Bad_Main is
   package Test is new Bad_Gen ("Test");
      ("bad main " & (if Test.Names.Max_Length > 2 then "OK" else "Fails"));
end Bad_Main;
with Ada.Strings.Bounded;

   Name: String := "";
package Bad_Gen is

   type Desc is tagged null record;

   --  D : Desc;

   function Size return Natural is ( if Desc'External_Tag'Length > 2 then

   package Names is new Ada.Strings.Bounded.Generic_Bounded_Length (Size);

   Test: Names.Bounded_String := Names.To_Bounded_String (Desc'External_Tag);

end Bad_Gen;

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

2014-10-23  Ed Schonberg  <>

	* sem_ch12.adb (Analyze_Associations): If an actual for a formal
	object is a call to a parameterless expression function, add
	the function to the list of actuals to freeze.
	* freeze.adb (Check_Expression_Function): Create freeze nodes of
	outer types that may be references in the body of the expression.

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]