]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
check.c (check_co_minmaxsum): Add definable check.
authorTobias Burnus <burnus@net-b.de>
Wed, 25 Jun 2014 20:26:42 +0000 (22:26 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Wed, 25 Jun 2014 20:26:42 +0000 (22:26 +0200)
gcc/fortran/
2014-06-25  Tobias Burnus  <burnus@net-b.de>

        * check.c (check_co_minmaxsum): Add definable check.
        * expr.c (gfc_check_vardef_context): Fix context == NULL case.
        * trans-expr.c (get_scalar_to_descriptor_type): Handle pointer
        arguments.
        * trans-intrinsic.c (gfc_conv_intrinsic_caf_get): Fix generation
        of temporary strings.

gcc/testsuite/
2014-06-25  Tobias Burnus  <burnus@net-b.de>

        * gfortran.dg/coarray_collectives_7.f90: New.

From-SVN: r211992

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

index b4bbb0a8a498115549f0012337a3af1db4927e12..12606ffeaa89a4a0e391941114e56be5506696c0 100644 (file)
@@ -1,3 +1,11 @@
+2014-06-25  Tobias Burnus  <burnus@net-b.de>
+
+       * check.c (check_co_minmaxsum): Add definable check.
+       * expr.c (gfc_check_vardef_context): Fix context == NULL case.
+       * trans-expr.c (get_scalar_to_descriptor_type): Handle pointer arguments.
+       * trans-intrinsic.c (gfc_conv_intrinsic_caf_get): Fix generation of temporary
+       strings.
+
 2014-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        * trans.h (gfc_omp_clause_linear_ctor): New prototype.
index bd3eff681568bd33c66f690cd65771d9251f5384..10944ebd2b13c7606ae5b0be92db57a0d6a33ff4 100644 (file)
@@ -1307,6 +1307,18 @@ check_co_minmaxsum (gfc_expr *a, gfc_expr *result_image, gfc_expr *stat,
   if (!variable_check (a, 0, false))
     return false;
 
+  if (!gfc_check_vardef_context (a, false, false, false, "argument 'A' with "
+                                "INTENT(INOUT)"))
+    return false;
+
+  if (gfc_has_vector_subscript (a))
+    {
+      gfc_error ("Argument 'A' with INTENT(INOUT) at %L of the intrinsic "
+                "subroutine %s shall not have a vector subscript",
+                &a->where, gfc_current_intrinsic);
+      return false;
+    }
+
   if (result_image != NULL)
     {
       if (!type_check (result_image, 1, BT_INTEGER))
index f0238c1b97ec1569d058f0e22b352a9453401211..feb089e480b063f341ecebe25045a829ec1ded42 100644 (file)
@@ -4956,10 +4956,11 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj,
                          en = n->expr;
                          if (gfc_dep_compare_expr (ec, en) == 0)
                            {
-                             gfc_error_now ("Elements with the same value at %L"
-                                            " and %L in vector subscript"
-                                            " in a variable definition"
-                                            " context (%s)", &(ec->where),
+                             if (context)
+                               gfc_error_now ("Elements with the same value at %L"
+                                              " and %L in vector subscript"
+                                              " in a variable definition"
+                                              " context (%s)", &(ec->where),
                                             &(en->where), context);
                              return false;
                            }
index d67d737f92d02cfbb98afba51da2cad39489b23f..7ee0206e6a0c385d8af1918c04b1f5486c3e9bf4 100644 (file)
@@ -57,6 +57,8 @@ get_scalar_to_descriptor_type (tree scalar, symbol_attribute attr)
   else
     akind = GFC_ARRAY_ASSUMED_SHAPE_CONT;
 
+  if (POINTER_TYPE_P (TREE_TYPE (scalar)))
+    scalar = TREE_TYPE (scalar);
   return gfc_get_array_type_bounds (TREE_TYPE (scalar), 0, 0, NULL, NULL, 1,
                                    akind, !(attr.pointer || attr.target));
 }
index 548fd9fbc769fdd341350f0b4211b96264279d5e..a0c74218e63170a29bbbec002dc8359cae00adbf 100644 (file)
@@ -1258,7 +1258,8 @@ gfc_conv_intrinsic_caf_get (gfc_se *se, gfc_expr *expr, tree lhs, tree lhs_kind)
        {
          gfc_clear_attr (&attr);
          if (array_expr->ts.type == BT_CHARACTER)
-           res_var = gfc_conv_string_tmp (se, type, argse.string_length);
+           res_var = gfc_conv_string_tmp (se, build_pointer_type (type),
+                                          argse.string_length);
          else
            res_var = gfc_create_var (type, "caf_res");
          dst_var = gfc_conv_scalar_to_descriptor (&argse, res_var, attr);
index 62c13c2b219712eb16fd2c897e9b1083f6d83471..7046ff741056a5acae7685d4a18c4679da64267a 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-25  Tobias Burnus  <burnus@net-b.de>
+
+       * gfortran.dg/coarray_collectives_7.f90: New.
+
 2014-06-25  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        * gcc.c-torture/execute/20140622-1.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/coarray_collectives_8.f90 b/gcc/testsuite/gfortran.dg/coarray_collectives_8.f90
new file mode 100644 (file)
index 0000000..aa97b7f
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+!
+! As SOURCE is INTENT(INOUT), it must be definable,
+! cf. J3/14-147
+!
+
+intrinsic :: co_sum, co_min, co_max
+integer :: vec(3), idx(3)
+
+call co_sum(vec(idx)) ! { dg-error "Argument 'A' with INTENT\\(INOUT\\) at .1. of the intrinsic subroutine co_sum shall not have a vector subscript" }
+call co_min(vec([1,3,2])) ! { dg-error "Argument 'A' with INTENT\\(INOUT\\) at .1. of the intrinsic subroutine co_min shall not have a vector subscript" }
+call co_sum(vec([1,1,1])) ! { dg-error "Elements with the same value at .1. and .2. in vector subscript in a variable definition context \\(argument 'A' with INTENT\\(INOUT\\)\\)" }
+end