[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Fri, 10 Apr 2009 10:21:44 +0000 (12:21 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 10 Apr 2009 10:21:44 +0000 (12:21 +0200)
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

gcc/ada/ChangeLog
gcc/ada/adaint.c
gcc/ada/exp_ch2.adb
gcc/ada/exp_ch9.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_res.adb

index 4aced676bd3417987a2d9d7f5f9a4e68fb257263..71291641b7445407bf7b744e00bdfe614d2b90d0 100644 (file)
@@ -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.
index 9a108ff707a86661a3639c8a733f04769f97426e..7d35f11b3e140014cb57932fe2e641a3277a8c1a 100644 (file)
 #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
index 3825405dccf1ed6ac584290be2421153482a02f3..2963ae872461f669fd3d0cf3133222386988e84c 100644 (file)
@@ -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))
index bff65b361d6fe082c6ba168ee9575e1979c63cee..a95835da3cf3541518ce92a54c585c4216b995a2 100644 (file)
@@ -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
index af25b1427cd785c65b8e2cc211f825a052e5ed19..544c6090922a58bd2cb8976a4afbbc9652a796c4 100644 (file)
@@ -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;
index a6c5aad9e593ebdf2869480813ac0473380dfeda..0d40e5afcffe4b94d9683cc46e86593075bd96dc 100644 (file)
@@ -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);