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]

Re: [patch, fortran] PR32360 'DATA PTR1 /NULL ()/' WHEN PTR1 HAS POINTER ATTRIBUTE


:REVIEWMAIL:


The attached patch allows the test case in the PR to compile. However, it conflicts with the testcase pr15754.f90. Do we want to allow this assignment as an extension or should I further refine the checking? Or is it valid to allow the assignment to NULL as in the PR?


     integer, pointer :: ptr1
     data ptr1 /NULL()/
     end

Regression tested on x86-64-Gnu-Linux.


And I figured out I did not have the patch quite right. Here is an update. With this patch there is no longer a problem with the test case pr15754.f90.


I was not checking for the data attribute.

Regression tested on x86-64 with no problems. pr15754.f90 passes as well as the new test case attached.

OK for trunk?

Jerry




Index: expr.c
===================================================================
*** expr.c	(revision 125937)
--- expr.c	(working copy)
*************** gfc_check_assign (gfc_expr *lvalue, gfc_
*** 2407,2418 ****
        return FAILURE;
      }
  
!    if (rvalue->expr_type == EXPR_NULL)
!      {
!        gfc_error ("NULL appears on right-hand side in assignment at %L",
! 		  &rvalue->where);
!        return FAILURE;
!      }
  
     if (sym->attr.cray_pointee
         && lvalue->ref != NULL
--- 2407,2424 ----
        return FAILURE;
      }
  
!   if (rvalue->expr_type == EXPR_NULL)
!     {  
!       if (lvalue->symtree->n.sym->attr.pointer
! 	  && lvalue->symtree->n.sym->attr.data)
!         return SUCCESS;
!       else
! 	{
! 	  gfc_error ("NULL appears on right-hand side in assignment at %L",
! 		     &rvalue->where);
! 	  return FAILURE;
! 	}
!     }
  
     if (sym->attr.cray_pointee
         && lvalue->ref != NULL
! { dg-do compile }
! PR32360 Won't compile 'data ptr1 /null ()/' when ptr1 has pointer attribute.
      integer, pointer :: ptr1
      data ptr1 /NULL()/
      end


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