2
0
mirror of git://gcc.gnu.org/git/gcc.git synced 2025-03-25 10:20:43 +08:00

[multiple changes]

2009-04-10  Ed Schonberg  <schonberg@adacore.com>

	* sem_prag.adb (Analyze_Pragma, case Task_Name): Do not expand argument
	of pragma. It will be recopied and analyzed when used in call to
	Create_Task.

	* sem_res.adb (Resolve_Call): Clarify use of secondary stack within
	initialization operations and recognize use of it in procedure calls
	within init_procs.

	* exp_ch9.adb (Make_Task_Create_Call): Copy full tree of Task_Name
	argument, because it may have side-effects.

	* exp_ch2.adb: Remove obsolete comments on default functions

2009-04-10  Jose Ruiz  <ruiz@adacore.com>

	* adaint.c (RTX section): Do for RTX the same thing as we do for
	Windows (include ctype.h and define a fallback ISALPHA if IN_RTS).

From-SVN: r145882
This commit is contained in:
Arnaud Charlet 2009-04-10 12:21:44 +02:00
parent 24357840f1
commit 4017021b35
6 changed files with 75 additions and 32 deletions

@ -1,3 +1,23 @@
2009-04-10 Ed Schonberg <schonberg@adacore.com>
* sem_prag.adb (Analyze_Pragma, case Task_Name): Do not expand argument
of pragma. It will be recopied and analyzed when used in call to
Create_Task.
* sem_res.adb (Resolve_Call): Clarify use of secondary stack within
initialization operations and recognize use of it in procedure calls
within init_procs.
* exp_ch9.adb (Make_Task_Create_Call): Copy full tree of Task_Name
argument, because it may have side-effects.
* exp_ch2.adb: Remove obsolete comments on default functions
2009-04-10 Jose Ruiz <ruiz@adacore.com>
* adaint.c (RTX section): Do for RTX the same thing as we do for
Windows (include ctype.h and define a fallback ISALPHA if IN_RTS).
2009-04-10 Robert Dewar <dewar@adacore.com>
* sem_aux.ads, sem_aux.adb (Nearest_Current_Scope): New function.

@ -75,14 +75,15 @@
#include "version.h"
#endif
#if defined (__MINGW32__)
#if defined (RTX)
#include <windows.h>
#include <Rtapi.h>
#include <sys/utime.h>
#elif defined (__MINGW32__)
#else
#include "mingw32.h"
#endif
#include <sys/utime.h>
/* For isalpha-like tests in the compiler, we're expected to resort to

@ -267,11 +267,9 @@ package body Exp_Ch2 is
end loop;
-- If the discriminant occurs within the default expression for a
-- formal of an entry or protected operation, create a default
-- function for it, and replace the discriminant with a reference to
-- the discriminant of the formal of the default function. The
-- discriminant entity is the one defined in the corresponding
-- record.
-- formal of an entry or protected operation, replace it with a
-- reference to the discriminant of the formal of the enclosing
-- operation.
if Present (Parent_P)
and then Present (Corresponding_Spec (Parent_P))
@ -284,8 +282,9 @@ package body Exp_Ch2 is
Disc : Entity_Id;
begin
-- Verify that we are within a default function: the type of
-- its formal parameter is the same task or protected type.
-- Verify that we are within the body of an entry or protected
-- operation. Its first formal parameter is the synchronized
-- type itself.
if Present (Formal)
and then Etype (Formal) = Scope (Entity (N))

@ -11990,8 +11990,11 @@ package body Exp_Ch9 is
if Present (Tdef)
and then Has_Task_Name_Pragma (Tdef)
then
-- Copy expression in full, because it may be dynamic and have
-- side effects.
Append_To (Args,
New_Copy (
New_Copy_Tree (
Expression (First (
Pragma_Argument_Associations (
Find_Task_Or_Protected_Pragma

@ -11168,7 +11168,11 @@ package body Sem_Prag is
Check_Arg_Count (1);
Arg := Expression (Arg1);
Analyze_And_Resolve (Arg, Standard_String);
-- The expression is used in the call to create_task, and must
-- be expanded there, not in the context of the current spec.
Preanalyze_And_Resolve (New_Copy_Tree (Arg), Standard_String);
if Nkind (P) /= N_Task_Definition then
Pragma_Misplaced;

@ -5043,28 +5043,38 @@ package body Sem_Res is
-- Create a transient scope if the resulting type requires it
-- There are 4 notable exceptions: in init procs, the transient scope
-- overhead is not needed and even incorrect due to the actual expansion
-- of adjust calls; the second case is enumeration literal pseudo calls;
-- the third case is intrinsic subprograms (Unchecked_Conversion and
-- source information functions) that do not use the secondary stack
-- even though the return type is unconstrained; the fourth case is a
-- call to a build-in-place function, since such functions may allocate
-- their result directly in a target object, and cases where the result
-- does get allocated in the secondary stack are checked for within the
-- specialized Exp_Ch6 procedures for expanding build-in-place calls.
-- There are several notable exceptions:
-- If this is an initialization call for a type whose initialization
-- uses the secondary stack, we also need to create a transient scope
-- for it, precisely because we will not do it within the init proc
-- itself.
-- a) in init procs, the transient scope overhead is not needed, and is
-- even incorrect when the call is a nested initialization call for a
-- component whose expansion may generate adjust calls. However, if the
-- call is some other procedure call within an initialization procedure
-- (for example a call to Create_Task in the init_proc of the task
-- run-time record) a transient scope must be created around this call.
-- If the subprogram is marked Inline_Always, then even if it returns
-- b) enumeration literal pseudo-calls need no transient scope.
-- c) intrinsic subprograms (Unchecked_Conversion and source info
-- functions) do not use the secondary stack even though the return
-- type may be unconstrained;
-- d) calls to a build-in-place function, since such functions may
-- allocate their result directly in a target object, and cases where
-- the result does get allocated in the secondary stack are checked for
-- within the specialized Exp_Ch6 procedures for expanding those
-- build-in-place calls.
-- e) If the subprogram is marked Inline_Always, then even if it returns
-- an unconstrained type the call does not require use of the secondary
-- stack. However, inlining will only take place if the body to inline
-- is already present. It may not be available if e.g. the subprogram is
-- declared in a child instance.
-- If this is an initialization call for a type whose construction
-- uses the secondary stack, and it is not a nested call to initialize
-- a component, we do need to create a transient scope for it. We
-- check for this by traversing the type in Check_Initialization_Call.
if Is_Inlined (Nam)
and then Has_Pragma_Inline_Always (Nam)
and then Nkind (Unit_Declaration_Node (Nam)) = N_Subprogram_Declaration
@ -5072,13 +5082,19 @@ package body Sem_Res is
then
null;
elsif Ekind (Nam) = E_Enumeration_Literal
or else Is_Build_In_Place_Function (Nam)
or else Is_Intrinsic_Subprogram (Nam)
then
null;
elsif Expander_Active
and then Is_Type (Etype (Nam))
and then Requires_Transient_Scope (Etype (Nam))
and then not Is_Build_In_Place_Function (Nam)
and then Ekind (Nam) /= E_Enumeration_Literal
and then not Within_Init_Proc
and then not Is_Intrinsic_Subprogram (Nam)
and then
(not Within_Init_Proc
or else
(not Is_Init_Proc (Nam) and then Ekind (Nam) /= E_Function))
then
Establish_Transient_Scope (N, Sec_Stack => True);