This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran] PR18769, PR25049 and PR25050 - transformational functions in initialization expressions.


:ADDPATCH fortran:

A number of transformational intrinsic functions are not permitted in initialization expressions (please see the standard or the ChangeLog for the list). These are not implemented in simplify.c and, in consequence, and ICE ensues on trying to deploy them in initialization expressions. This patch detects the incorrect usage in check.c and emits an error there. check.c was chosen because no further selection of intrinsic funtions was needed; the usual mechanism applies.

On the other hand, TRANSFER is allowed but is not implemented in gfortran (PR18769). I have added a gfc_simply_transfer as a placeholder for its implementation. At present, it emits an error. I propose to keep the PR open and, since I am in full flood on constructors right now, I have assigned it to myself!

I suggest that a testcase is not necessary for this patch, although I will provide one for PR18769, when it is fixed.

Regtested on FC5/Athlon. OK for trunk and 4.1?

Paul

2006-06-18 Paul Thomas <pault@gcc.gnu.org>

   PR fortran/25049
   PR fortran/25050
   * check.c (non_init_transformational): New function.
   (find_substring_ref): New function to signal use of disallowed
   transformational intrinsic in an initialization expression.
   (gfc_check_all_any): Call previous if initialization expr.
   (gfc_check_count): The same.
   (gfc_check_cshift): The same.
   (gfc_check_dot_product): The same.
   (gfc_check_eoshift): The same.
   (gfc_check_minloc_maxloc): The same.
   (gfc_check_minval_maxval): The same.
   (gfc_check_gfc_check_product_sum): The same.
   (gfc_check_pack): The same.
   (gfc_check_spread): The same.
   (gfc_check_transpose): The same.
   (gfc_check_unpack): The same.

   PR fortran/18769
   *intrinsic.c (add_functions): Add gfc_simplify_transfer.
   *intrinsic.h : Add prototype for gfc_simplify_transfer.
   *simplify.c (gfc_simplify_transfer) : New function to act as
   placeholder for eventual implementation.  Emit error for now.




Index: gcc/fortran/check.c
===================================================================
*** gcc/fortran/check.c	(revision 114548)
--- gcc/fortran/check.c	(working copy)
*************** identical_dimen_shape (gfc_expr *a, int 
*** 378,383 ****
--- 378,395 ----
    return ret;
  }
  
+ /* Error return for transformational intrinsics not allowed in
+    initalization expressions.  */
+  
+ static try
+ non_init_transformational (void)
+ {
+   gfc_error ("transformational intrinsic '%s' at %L is not permitted "
+ 	     "in an initialization expression", gfc_current_intrinsic,
+ 	     gfc_current_intrinsic_where);
+   return FAILURE;
+ }
+ 
  /***** Check functions *****/
  
  /* Check subroutine suitable for intrinsics taking a real argument and
*************** gfc_check_all_any (gfc_expr * mask, gfc_
*** 439,444 ****
--- 451,459 ----
    if (dim_check (dim, 1, 1) == FAILURE)
      return FAILURE;
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return SUCCESS;
  }
  
*************** gfc_check_count (gfc_expr * mask, gfc_ex
*** 724,729 ****
--- 739,747 ----
    if (dim_check (dim, 1, 1) == FAILURE)
      return FAILURE;
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return SUCCESS;
  }
  
*************** gfc_check_cshift (gfc_expr * array, gfc_
*** 747,752 ****
--- 765,773 ----
    if (dim_check (dim, 2, 1) == FAILURE)
      return FAILURE;
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return SUCCESS;
  }
  
*************** gfc_check_dot_product (gfc_expr * vector
*** 848,853 ****
--- 869,877 ----
        return FAILURE;
      }
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return SUCCESS;
  }
  
*************** gfc_check_eoshift (gfc_expr * array, gfc
*** 883,888 ****
--- 907,915 ----
    if (dim_check (dim, 1, 1) == FAILURE)
      return FAILURE;
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return SUCCESS;
  }
  
*************** gfc_check_matmul (gfc_expr * matrix_a, g
*** 1545,1550 ****
--- 1572,1580 ----
        return FAILURE;
      }
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return SUCCESS;
  }
  
*************** gfc_check_minloc_maxloc (gfc_actual_argl
*** 1605,1610 ****
--- 1635,1643 ----
  	return FAILURE;
      }
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return SUCCESS;
  }
  
*************** gfc_check_minval_maxval (gfc_actual_argl
*** 1673,1678 ****
--- 1706,1714 ----
        || array_check (ap->expr, 0) == FAILURE)
      return FAILURE;
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return check_reduction (ap);
  }
  
*************** gfc_check_product_sum (gfc_actual_arglis
*** 1684,1689 ****
--- 1720,1728 ----
        || array_check (ap->expr, 0) == FAILURE)
      return FAILURE;
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return check_reduction (ap);
  }
  
*************** gfc_check_pack (gfc_expr * array, gfc_ex
*** 1781,1786 ****
--- 1820,1828 ----
        /* TODO: More constraints here.  */
      }
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return SUCCESS;
  }
  
*************** gfc_check_spread (gfc_expr * source, gfc
*** 2152,2157 ****
--- 2194,2202 ----
    if (scalar_check (ncopies, 2) == FAILURE)
      return FAILURE;
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return SUCCESS;
  }
  
*************** gfc_check_transpose (gfc_expr * matrix)
*** 2367,2372 ****
--- 2412,2420 ----
    if (rank_check (matrix, 0, 2) == FAILURE)
      return FAILURE;
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return SUCCESS;
  }
  
*************** gfc_check_unpack (gfc_expr * vector, gfc
*** 2405,2410 ****
--- 2453,2461 ----
    if (same_type_check (vector, 0, field, 2) == FAILURE)
      return FAILURE;
  
+   if (gfc_init_expr)
+     return non_init_transformational ();
+ 
    return SUCCESS;
  }
  
Index: gcc/fortran/intrinsic.c
===================================================================
*** gcc/fortran/intrinsic.c	(revision 114548)
--- gcc/fortran/intrinsic.c	(working copy)
*************** add_functions (void)
*** 2139,2145 ****
    make_generic ("tiny", GFC_ISYM_NONE, GFC_STD_F95);
  
    add_sym_3 ("transfer", 0, 1, BT_REAL, dr, GFC_STD_F95,
! 	     gfc_check_transfer, NULL, gfc_resolve_transfer,
  	     src, BT_REAL, dr, REQUIRED, mo, BT_REAL, dr, REQUIRED,
  	     sz, BT_INTEGER, di, OPTIONAL);
  
--- 2139,2145 ----
    make_generic ("tiny", GFC_ISYM_NONE, GFC_STD_F95);
  
    add_sym_3 ("transfer", 0, 1, BT_REAL, dr, GFC_STD_F95,
! 	     gfc_check_transfer, gfc_simplify_transfer, gfc_resolve_transfer,
  	     src, BT_REAL, dr, REQUIRED, mo, BT_REAL, dr, REQUIRED,
  	     sz, BT_INTEGER, di, OPTIONAL);
  
Index: gcc/fortran/intrinsic.h
===================================================================
*** gcc/fortran/intrinsic.h	(revision 114548)
--- gcc/fortran/intrinsic.h	(working copy)
*************** gfc_expr *gfc_simplify_sqrt (gfc_expr *)
*** 276,281 ****
--- 276,282 ----
  gfc_expr *gfc_simplify_tan (gfc_expr *);
  gfc_expr *gfc_simplify_tanh (gfc_expr *);
  gfc_expr *gfc_simplify_tiny (gfc_expr *);
+ gfc_expr *gfc_simplify_transfer (gfc_expr *, gfc_expr *, gfc_expr *);
  gfc_expr *gfc_simplify_trim (gfc_expr *);
  gfc_expr *gfc_simplify_ubound (gfc_expr *, gfc_expr *);
  gfc_expr *gfc_simplify_verify (gfc_expr *, gfc_expr *, gfc_expr *);
Index: gcc/fortran/simplify.c
===================================================================
*** gcc/fortran/simplify.c	(revision 114548)
--- gcc/fortran/simplify.c	(working copy)
*************** gfc_simplify_tiny (gfc_expr * e)
*** 3696,3701 ****
--- 3696,3712 ----
  
  
  gfc_expr *
+ gfc_simplify_transfer (gfc_expr * source, gfc_expr *mold, gfc_expr * size)
+ {
+ 
+   gfc_error ("TRANSFER intrinsic not implemented for initialization at %L",
+ 	     &source->where);
+ 
+   return gfc_copy_expr (mold);
+ }
+ 
+ 
+ gfc_expr *
  gfc_simplify_trim (gfc_expr * e)
  {
    gfc_expr *result;
2006-06-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/25049
	PR fortran/25050
	* check.c (non_init_transformational): New function.
	(find_substring_ref): New function to signal use of disallowed
	transformational intrinsic in an initialization expression.
	(gfc_check_all_any): Call previous if initialization expr.
	(gfc_check_count): The same.
	(gfc_check_cshift): The same.
	(gfc_check_dot_product): The same.
	(gfc_check_eoshift): The same.
	(gfc_check_minloc_maxloc): The same.
	(gfc_check_minval_maxval): The same.
	(gfc_check_gfc_check_product_sum): The same.
	(gfc_check_pack): The same.
	(gfc_check_spread): The same.
	(gfc_check_transpose): The same.
	(gfc_check_unpack): The same.

	PR fortran/18769
	*intrinsic.c (add_functions): Add gfc_simplify_transfer.
	*intrinsic.h : Add prototype for gfc_simplify_transfer.
	*simplify.c (gfc_simplify_transfer) : New function to act as
	placeholder for eventual implementation.  Emit error for now.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]