re PR fortran/32823 (internal compiler error: in gfc_trans_assignment_1)
authorLee Millward <lee.millward@gmail.com>
Sat, 21 Jul 2007 17:59:39 +0000 (17:59 +0000)
committerLee Millward <lmillward@gcc.gnu.org>
Sat, 21 Jul 2007 17:59:39 +0000 (17:59 +0000)
        PR fortran/32823
        * trans-intrinsic.c (gfc_conv_intrinsic_int): Evaluate all
        arguments passed, not just the first one. Adjust code to refer
        to "args[0]" instead of "arg" as a result.

        * gfortran.dg/int_2.f90: New test.

From-SVN: r126810

gcc/fortran/ChangeLog
gcc/fortran/trans-intrinsic.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/int_2.f90 [new file with mode: 0644]

index 476b73eb22d9884a95f03364052439bfc5e21fc3..575e1e947f3fa51b1353d8bf1a75770db78757e3 100644 (file)
@@ -1,3 +1,10 @@
+2007-07-21  Lee Millward  <lee.millward@gmail.com>
+
+       PR fortran/32823
+       * trans-intrinsic.c (gfc_conv_intrinsic_int): Evaluate all
+       arguments passed, not just the first one. Adjust code to 
+       refer to "args[0]" instead of "arg" as a result.
+       
 2007-07-19  Christopher D. Rickett  <crickett@lanl.gov>
 
        PR fortran/32600
index e1383f65fb50e982081007de2fbdfff077df50f2..02a64e53193cc4e7417c623c1218420a670078fc 100644 (file)
@@ -479,32 +479,37 @@ static void
 gfc_conv_intrinsic_int (gfc_se * se, gfc_expr * expr, enum rounding_mode op)
 {
   tree type;
-  tree arg;
+  tree *args;
+  int nargs;
 
-  /* Evaluate the argument.  */
+  nargs = gfc_intrinsic_argument_list_length (expr);
+  args = alloca (sizeof (tree) * nargs);
+
+  /* Evaluate the argument, we process all arguments even though we only 
+     use the first one for code generation purposes.  */
   type = gfc_typenode_for_spec (&expr->ts);
   gcc_assert (expr->value.function.actual->expr);
-  gfc_conv_intrinsic_function_args (se, expr, &arg, 1);
+  gfc_conv_intrinsic_function_args (se, expr, args, nargs);
 
-  if (TREE_CODE (TREE_TYPE (arg)) == INTEGER_TYPE)
+  if (TREE_CODE (TREE_TYPE (args[0])) == INTEGER_TYPE)
     {
       /* Conversion to a different integer kind.  */
-      se->expr = convert (type, arg);
+      se->expr = convert (type, args[0]);
     }
   else
     {
       /* Conversion from complex to non-complex involves taking the real
          component of the value.  */
-      if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE
+      if (TREE_CODE (TREE_TYPE (args[0])) == COMPLEX_TYPE
          && expr->ts.type != BT_COMPLEX)
        {
          tree artype;
 
-         artype = TREE_TYPE (TREE_TYPE (arg));
-         arg = build1 (REALPART_EXPR, artype, arg);
+         artype = TREE_TYPE (TREE_TYPE (args[0]));
+         args[0] = build1 (REALPART_EXPR, artype, args[0]);
        }
 
-      se->expr = build_fix_expr (&se->pre, arg, type, op);
+      se->expr = build_fix_expr (&se->pre, args[0], type, op);
     }
 }
 
index 2f83a2aeb2ff75293397b78285f3725fad18eba7..d4816ec5f8916982e18445fe68d1e5ff388bc83d 100644 (file)
@@ -1,3 +1,8 @@
+2007-07-21  Lee Millward  <lee.millward@gmail.com>
+
+       PR fortran/32823
+       * gfortran.dg/int_2.f90: New test.
+       
 2007-07-21  Rask Ingemann Lambertsen  <rask@sygehus.dk>
 
        * gcc.dg/inline-23.c: Use pointer sized type for cast from pointer.
diff --git a/gcc/testsuite/gfortran.dg/int_2.f90 b/gcc/testsuite/gfortran.dg/int_2.f90
new file mode 100644 (file)
index 0000000..b9a3ec4
--- /dev/null
@@ -0,0 +1,28 @@
+! PR fortran/32823
+! { dg-do compile }
+! { dg-final { cleanup-modules "token_module" } }
+
+module token_module
+
+      integer,     parameter :: INT8  = SELECTED_INT_KIND(16)
+      integer,     parameter :: REAL8 = SELECTED_REAL_KIND(12)
+
+contains
+      subroutine token_allreduce_i8_v(dowhat, array, result, length)
+
+
+        character(*),  intent(in)    :: dowhat
+        integer,       intent(in)    :: length
+        integer(INT8), intent(in)    :: array(*)
+        integer(INT8), intent(inout) :: result(*)
+
+
+        real(REAL8) :: copy_r8(length), result_r8(length)
+
+
+          result(1:length) = int(result_r8(1:length), INT8)
+
+
+      end subroutine token_allreduce_i8_v
+
+end module token_module