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 crash on expression function that is a completion


This change fixes a crash on an expression function which is the completion of
a previous declaration, when the type of the expression is a record type which
contains private components.

Such a code is illegal as per AI12-0103, which says that expression functions
that are a completion freeze their expression (but don't freeze anything else),
and must therefore be properly rejected.

Compiling the following package:

package P is

   type Cursor is private;

   package Nested is

      type Rec is record
         C : Cursor;
      end record;

      function F (R : Rec) return Rec;

   private

      function F (R : Rec) return Rec is (R);

   end Nested;

private

   type Cursor is null record;

end P;

must yield:

p.ads:15:43: premature usage of incomplete type "Rec" defined at line 7
p.ads:15:43: type "Rec" has private component

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

2017-09-08  Eric Botcazou  <ebotcazou@adacore.com>

	* sem_ch6.adb (Freeze_Expr_Types): Really freeze
	all the types that are referenced by the expression.
	(Analyze_Expression_Function): Call Freeze_Expr_Types for
	a completion instead of manually freezing the type of the
	expression.
	(Analyze_Subprogram_Body_Helper): Do not call Freeze_Expr_Types here.

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]