Commit a1092b48 by Arnaud Charlet

[multiple changes]

2011-11-23  Pascal Obry  <obry@adacore.com>

	* sem_prag.adb (Process_Convention): Better error message for
	stdcall convention on dispatching calls.

2011-11-23  Gary Dismukes  <dismukes@adacore.com>

	* sem_ch4.adb, sem_ch13.adb: Minor reformatting.

2011-11-23  Javier Miranda  <miranda@adacore.com>

	* exp_ch6.adb (Expand_Simple_Function_Return): Add missing
	implicit type conversion when the returned object is allocated
	in the secondary stack and the type of the returned object is
	an interface. Done to force generation of displacement of the
	"this" pointer.

From-SVN: r181657
parent 3d0c15cf
2011-11-23 Pascal Obry <obry@adacore.com> 2011-11-23 Pascal Obry <obry@adacore.com>
* sem_prag.adb (Process_Convention): Better error message for
stdcall convention on dispatching calls.
2011-11-23 Gary Dismukes <dismukes@adacore.com>
* sem_ch4.adb, sem_ch13.adb: Minor reformatting.
2011-11-23 Javier Miranda <miranda@adacore.com>
* exp_ch6.adb (Expand_Simple_Function_Return): Add missing
implicit type conversion when the returned object is allocated
in the secondary stack and the type of the returned object is
an interface. Done to force generation of displacement of the
"this" pointer.
2011-11-23 Pascal Obry <obry@adacore.com>
* impunit.adb: Add g-exptty and g-tty units. * impunit.adb: Add g-exptty and g-tty units.
2011-11-23 Robert Dewar <dewar@adacore.com> 2011-11-23 Robert Dewar <dewar@adacore.com>
......
...@@ -6700,6 +6700,14 @@ package body Exp_Ch6 is ...@@ -6700,6 +6700,14 @@ package body Exp_Ch6 is
Make_Explicit_Dereference (Loc, Make_Explicit_Dereference (Loc,
Prefix => New_Reference_To (Temp, Loc))); Prefix => New_Reference_To (Temp, Loc)));
-- Ada 2005 (AI-251): If the type of the returned object is
-- an interface then add an implicit type conversion to force
-- displacement of the "this" pointer.
if Is_Interface (R_Type) then
Rewrite (Exp, Convert_To (R_Type, Relocate_Node (Exp)));
end if;
Analyze_And_Resolve (Exp, R_Type); Analyze_And_Resolve (Exp, R_Type);
end; end;
......
...@@ -161,15 +161,15 @@ package body Sem_Ch13 is ...@@ -161,15 +161,15 @@ package body Sem_Ch13 is
---------------------------------------------- ----------------------------------------------
-- The following table collects unchecked conversions for validation. -- The following table collects unchecked conversions for validation.
-- Entries are made by Validate_Unchecked_Conversion and then the -- Entries are made by Validate_Unchecked_Conversion and then the call
-- call to Validate_Unchecked_Conversions does the actual error -- to Validate_Unchecked_Conversions does the actual error checking and
-- checking and posting of warnings. The reason for this delayed -- posting of warnings. The reason for this delayed processing is to take
-- processing is to take advantage of back-annotations of size and -- advantage of back-annotations of size and alignment values performed by
-- alignment values performed by the back end. -- the back end.
-- Note: the reason we store a Source_Ptr value instead of a Node_Id -- Note: the reason we store a Source_Ptr value instead of a Node_Id is
-- is that by the time Validate_Unchecked_Conversions is called, Sprint -- that by the time Validate_Unchecked_Conversions is called, Sprint will
-- will already have modified all Sloc values if the -gnatD option is set. -- already have modified all Sloc values if the -gnatD option is set.
type UC_Entry is record type UC_Entry is record
Eloc : Source_Ptr; -- node used for posting warnings Eloc : Source_Ptr; -- node used for posting warnings
...@@ -193,13 +193,13 @@ package body Sem_Ch13 is ...@@ -193,13 +193,13 @@ package body Sem_Ch13 is
-- for X'Address use Expr -- for X'Address use Expr
-- where Expr is of the form Y'Address or recursively is a reference -- where Expr is of the form Y'Address or recursively is a reference to a
-- to a constant of either of these forms, and X and Y are entities of -- constant of either of these forms, and X and Y are entities of objects,
-- objects, then if Y has a smaller alignment than X, that merits a -- then if Y has a smaller alignment than X, that merits a warning about
-- warning about possible bad alignment. The following table collects -- possible bad alignment. The following table collects address clauses of
-- address clauses of this kind. We put these in a table so that they -- this kind. We put these in a table so that they can be checked after the
-- can be checked after the back end has completed annotation of the -- back end has completed annotation of the alignments of objects, since we
-- alignments of objects, since we can catch more cases that way. -- can catch more cases that way.
type Address_Clause_Check_Record is record type Address_Clause_Check_Record is record
N : Node_Id; N : Node_Id;
...@@ -8618,8 +8618,8 @@ package body Sem_Ch13 is ...@@ -8618,8 +8618,8 @@ package body Sem_Ch13 is
Target := Ancestor_Subtype (Etype (Act_Unit)); Target := Ancestor_Subtype (Etype (Act_Unit));
-- If either type is generic, the instantiation happens within a generic -- If either type is generic, the instantiation happens within a generic
-- unit, and there is nothing to check. The proper check -- unit, and there is nothing to check. The proper check will happen
-- will happen when the enclosing generic is instantiated. -- when the enclosing generic is instantiated.
if Is_Generic_Type (Source) or else Is_Generic_Type (Target) then if Is_Generic_Type (Source) or else Is_Generic_Type (Target) then
return; return;
...@@ -8717,9 +8717,8 @@ package body Sem_Ch13 is ...@@ -8717,9 +8717,8 @@ package body Sem_Ch13 is
end if; end if;
-- If unchecked conversion to access type, and access type is declared -- If unchecked conversion to access type, and access type is declared
-- in the same unit as the unchecked conversion, then set the -- in the same unit as the unchecked conversion, then set the flag
-- No_Strict_Aliasing flag (no strict aliasing is implicit in this -- No_Strict_Aliasing (no strict aliasing is implicit here)
-- situation).
if Is_Access_Type (Target) and then if Is_Access_Type (Target) and then
In_Same_Source_Unit (Target, N) In_Same_Source_Unit (Target, N)
...@@ -8727,11 +8726,11 @@ package body Sem_Ch13 is ...@@ -8727,11 +8726,11 @@ package body Sem_Ch13 is
Set_No_Strict_Aliasing (Implementation_Base_Type (Target)); Set_No_Strict_Aliasing (Implementation_Base_Type (Target));
end if; end if;
-- Generate N_Validate_Unchecked_Conversion node for back end in -- Generate N_Validate_Unchecked_Conversion node for back end in case
-- case the back end needs to perform special validation checks. -- the back end needs to perform special validation checks.
-- Shouldn't this be in Exp_Ch13, since the check only gets done -- Shouldn't this be in Exp_Ch13, since the check only gets done if we
-- if we have full expansion and the back end is called ??? -- have full expansion and the back end is called ???
Vnode := Vnode :=
Make_Validate_Unchecked_Conversion (Sloc (N)); Make_Validate_Unchecked_Conversion (Sloc (N));
......
...@@ -3432,8 +3432,8 @@ package body Sem_Ch4 is ...@@ -3432,8 +3432,8 @@ package body Sem_Ch4 is
-- of the high bound. -- of the high bound.
procedure Check_Universal_Expression (N : Node_Id); procedure Check_Universal_Expression (N : Node_Id);
-- In Ada83, reject bounds of a universal range that are not literals or -- In Ada 83, reject bounds of a universal range that are not literals
-- entity names. -- or entity names.
----------------------- -----------------------
-- Check_Common_Type -- -- Check_Common_Type --
......
...@@ -3526,16 +3526,22 @@ package body Sem_Prag is ...@@ -3526,16 +3526,22 @@ package body Sem_Prag is
-- Stdcall case -- Stdcall case
if C = Convention_Stdcall if C = Convention_Stdcall then
-- A dispatching call is not allowed. A dispatching subprogram
-- cannot be used to interface to the Win32 API, so in fact this
-- check does not impose any effective restriction.
if Is_Dispatching_Operation (E) then
Error_Pragma
("dispatching subprograms cannot use Stdcall convention");
-- Subprogram is allowed, but not a generic subprogram, and not a -- Subprogram is allowed, but not a generic subprogram, and not a
-- dispatching operation. A dispatching subprogram cannot be used -- dispatching operation.
-- to interface to the Win32 API, so in fact this check does not
-- impose any effective restriction.
and then elsif not Is_Subprogram (E)
((not Is_Subprogram (E) and then not Is_Generic_Subprogram (E)) and then not Is_Generic_Subprogram (E)
or else Is_Dispatching_Operation (E))
-- A variable is OK -- A variable is OK
...@@ -3551,6 +3557,7 @@ package body Sem_Prag is ...@@ -3551,6 +3557,7 @@ package body Sem_Prag is
("second argument of pragma% must be subprogram (type)", ("second argument of pragma% must be subprogram (type)",
Arg2); Arg2);
end if; end if;
end if;
if not Is_Subprogram (E) if not Is_Subprogram (E)
and then not Is_Generic_Subprogram (E) and then not Is_Generic_Subprogram (E)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment