aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2009-04-10 12:21:44 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2009-04-10 12:21:44 +0200
commit4017021b3585d2d9c0ce2521e32fa0a532c25cab (patch)
treebf94e39042c5b3d4750165692d29ac1028365b68
parent24357840f1d9fbeb5f604b33b541479786d9910a (diff)
downloadgcc-4017021b3585d2d9c0ce2521e32fa0a532c25cab.zip
gcc-4017021b3585d2d9c0ce2521e32fa0a532c25cab.tar.gz
gcc-4017021b3585d2d9c0ce2521e32fa0a532c25cab.tar.bz2
[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
-rw-r--r--gcc/ada/ChangeLog20
-rw-r--r--gcc/ada/adaint.c9
-rw-r--r--gcc/ada/exp_ch2.adb13
-rw-r--r--gcc/ada/exp_ch9.adb5
-rw-r--r--gcc/ada/sem_prag.adb6
-rw-r--r--gcc/ada/sem_res.adb58
6 files changed, 77 insertions, 34 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 4aced67..7129164 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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.
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 9a108ff..7d35f11 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -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
diff --git a/gcc/ada/exp_ch2.adb b/gcc/ada/exp_ch2.adb
index 3825405..2963ae8 100644
--- a/gcc/ada/exp_ch2.adb
+++ b/gcc/ada/exp_ch2.adb
@@ -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))
diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
index bff65b3..a95835d 100644
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -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
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index af25b14..544c609 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -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;
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index a6c5aad..0d40e5a 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -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.
-
- -- 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.
-
- -- If the subprogram is marked Inline_Always, then even if it returns
+ -- There are several notable exceptions:
+
+ -- 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.
+
+ -- 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);