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] Make assoicated(null-pointer-to-scalar,null-pointer-to-scalar) return .FALSE. (PR30238)


:ADDPATCH fortran:

Fixes
    assoicated(null-pointer-to-scalar,null-pointer-to-scalar)
contrary to the patch before, this is for scalars (in
trans-intrinsics.c), before it was for arrays (libgfortran).

Changing trans-intrinsic.c was easier than I thought. Result for a
simple test case
(integer, pointer :: i; nullify(i); if(associated(i,i)) call abort()), now:

  int4 * i;
  _gfortran_set_std (70, 127, 0);
  i = 0B;
  if (i == i && i != 0B)
    {
      _gfortran_abort ();
    }



Regtested x86_64-unknown-linux-gnu.
Ok for trunk and 4.2?

Tobias


2006-12-17  Tobias Burnus  <burnus@net-b.de>

	PR fortran/39238
	* trans-intrinsic.c: Check for associated(NULL,NULL).

2006-12-17  Tobias Burnus  <burnus@net-b.de>

	PR fortran/39238
	* gfortran.dg/associated_1.f90: Add test for associated(NULL,NULL).

Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c	(Revision 119989)
+++ gcc/fortran/trans-intrinsic.c	(Arbeitskopie)
@@ -3142,7 +3142,9 @@
 	  gfc_add_block_to_block (&se->pre, &arg1se.pre);
 	  gfc_add_block_to_block (&se->post, &arg1se.post);
           tmp = build2 (EQ_EXPR, boolean_type_node, arg1se.expr, arg2se.expr);
-          se->expr = tmp;
+          tmp2 = build2 (NE_EXPR, boolean_type_node, arg1se.expr,
+                         null_pointer_node);
+          se->expr = build2 (TRUTH_AND_EXPR, boolean_type_node, tmp, tmp2);
         }
       else
         {
Index: gcc/testsuite/gfortran.dg/associated_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/associated_1.f90	(Revision 119989)
+++ gcc/testsuite/gfortran.dg/associated_1.f90	(Arbeitskopie)
@@ -4,7 +4,10 @@
 program test
    real, pointer :: a, b
 
+   nullify(a,b)
+   if(associated(a,b).or.associated(a,a)) call abort()
    allocate(a)
+   if(associated(b,a)) call abort()
    if (.not.associated(x(a))) call abort ()
    if (.not.associated(a, x(a))) call abort ()
 

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