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] PR27655 - NULL as the pointer in the associated intinsic causes ICE


FX found the following unpleasantness:

print *, associated(NULL(),NULL())
end
$ gfortran null.f90
null.f90:0: internal compiler error: in gfc_check_associated, at
fortran/check.c:508


The patch is as trivial as can be, up to the decision to use goto to get to the error for NULL as an unacceptable actual argument for associated. As I say in the comment, this seemed to be the least inelegant way of achieving the require result. An alternative would be to take the error return out of the if statement and have two goto's to the error return.


I saw no point in a testcase for this PR. However, since it would a minimum of effort, I could be convinced otherwise.

Regtests on FC5/Athlon1700. OK for trunk and 4.1?

Paul

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

   PR fortran/25090
   * check.c (gfc_check_associated): If the pointer itself is a
   null expression, jump past the other checks to the error that
   rejects NULL pointer as an actual argument for associated.


Index: gcc/fortran/check.c
===================================================================
*** gcc/fortran/check.c	(revision 114148)
--- gcc/fortran/check.c	(working copy)
*************** gfc_check_associated (gfc_expr * pointer
*** 504,509 ****
--- 504,512 ----
      attr = gfc_variable_attr (pointer, NULL);
    else if (pointer->expr_type == EXPR_FUNCTION)
      attr = pointer->symtree->n.sym->attr;
+   else if (pointer->expr_type == EXPR_NULL)
+     /* This is the least inelegant way of trapping this error!  */
+     goto pointer_expr_null;
    else
      gcc_assert (0); /* Pointer must be a variable or a function.  */
  
*************** gfc_check_associated (gfc_expr * pointer
*** 521,526 ****
--- 524,531 ----
  
    if (target->expr_type == EXPR_NULL)
      {
+ pointer_expr_null:
+ 
        gfc_error ("NULL pointer at %L is not permitted as actual argument "
                   "of '%s' intrinsic function",
                   &target->where, gfc_current_intrinsic);
2006-06-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/25090
	* check.c (gfc_check_associated): If the pointer itself is a
	null expression, jump past the other checks to the error that
	rejects NULL pointer as an actual argument for associated.


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