diff mbox

[fortran] Further dependency improvements

Message ID 1282983112.3506.1.camel@linux-fd1f.site
State New
Headers show

Commit Message

Thomas Koenig Aug. 28, 2010, 8:11 a.m. UTC
Hello world,

now I'm back from my holiday, here is another round of dependency
improvements.  This patch is fairly self-explanatory.

OK for trunk?

	Thomas

2010-08-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/45159
	* dependency.c (gfc_deb_compare_expr):  Compare equal for equal
	arglists for pure user functions, or for those intrinsic
	functions which are also pure.

2010-08-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/45159
	* gfortran.dg/dependency_34.f90:  New test.

Comments

Daniel Kraft Aug. 28, 2010, 8:31 a.m. UTC | #1
Thomas Koenig wrote:
> Hello world,
> 
> now I'm back from my holiday, here is another round of dependency
> improvements.  This patch is fairly self-explanatory.
> 
> OK for trunk?

Hi Thomas,

not a review but just a small comment:

+	      /* List of intrinsic functions with side effects or which
+		 may compare unequal for equal arguments.  */
+	    case GFC_ISYM_CHDIR:
+	    case GFC_ISYM_CHMOD:
+	    case GFC_ISYM_DTIME:
+	    case GFC_ISYM_ETIME:
+	    case GFC_ISYM_FDATE:
+	    case GFC_ISYM_FGET:
+	    case GFC_ISYM_FGETC:
+	    case GFC_ISYM_FNUM:
+	    case GFC_ISYM_FPUT:
...

I think that we introduced CLASS_PURE / CLASS_IMPURE for intrinsics 
lately -- and would suggest to use that information instead of 
duplicating the list here.  Although I do not completely remember 
whether that is already set correctly or not.

Daniel
diff mbox

Patch

Index: dependency.c
===================================================================
--- dependency.c	(Revision 163584)
+++ dependency.c	(Arbeitskopie)
@@ -353,29 +353,77 @@  gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
       return -2;
 
     case EXPR_FUNCTION:
+
+      /* PURE user functions can be compared for equality.  */
+      if (e1->value.function.esym && e2->value.function.esym
+	  && e1->value.function.esym == e2->value.function.esym
+	  && e1->value.function.esym->result->attr.pure)
+	goto compare_arglists;
+      
       /* We can only compare calls to the same intrinsic function.  */
-      if (e1->value.function.isym == 0 || e2->value.function.isym == 0
-	  || e1->value.function.isym != e2->value.function.isym)
-	return -2;
-
-      args1 = e1->value.function.actual;
-      args2 = e2->value.function.actual;
-
-      /* We should list the "constant" intrinsic functions.  Those
-	 without side-effects that provide equal results given equal
-	 argument lists.  */
-      switch (e1->value.function.isym->id)
+      if (e1->value.function.isym && e2->value.function.isym
+	  && e1->value.function.isym == e2->value.function.isym)
 	{
+	  switch (e1->value.function.isym->id)
+	    {
 
-	case GFC_ISYM_REAL:
-	case GFC_ISYM_LOGICAL:
-	case GFC_ISYM_DBLE:
-	  break;
+	      /* List of intrinsic functions with side effects or which
+		 may compare unequal for equal arguments.  */
+	    case GFC_ISYM_CHDIR:
+	    case GFC_ISYM_CHMOD:
+	    case GFC_ISYM_DTIME:
+	    case GFC_ISYM_ETIME:
+	    case GFC_ISYM_FDATE:
+	    case GFC_ISYM_FGET:
+	    case GFC_ISYM_FGETC:
+	    case GFC_ISYM_FNUM:
+	    case GFC_ISYM_FPUT:
+	    case GFC_ISYM_FPUTC:
+	    case GFC_ISYM_FSTAT:
+	    case GFC_ISYM_FTELL:
+	    case GFC_ISYM_GETCWD:
+	    case GFC_ISYM_GETGID:
+	    case GFC_ISYM_GETPID:
+	    case GFC_ISYM_GETUID:
+	    case GFC_ISYM_HOSTNM:
+	    case GFC_ISYM_IERRNO:
+	    case GFC_ISYM_IRAND:
+	    case GFC_ISYM_IMAGE_INDEX:
+	    case GFC_ISYM_ISATTY:
+	    case GFC_ISYM_KILL:
+	    case GFC_ISYM_LINK:
+	    case GFC_ISYM_MALLOC:
+	    case GFC_ISYM_MCLOCK:
+	    case GFC_ISYM_MCLOCK8:
+	    case GFC_ISYM_MOVE_ALLOC:
+	    case GFC_ISYM_NUMIMAGES:
+	    case GFC_ISYM_RAND:
+	    case GFC_ISYM_RENAME:
+	    case GFC_ISYM_SECNDS:
+	    case GFC_ISYM_SECOND:
+	    case GFC_ISYM_SIGNAL:
+	    case GFC_ISYM_STAT:
+	    case GFC_ISYM_SYMLINK:
+	    case GFC_ISYM_SYMLNK:
+	    case GFC_ISYM_SYSTEM:
+	    case GFC_ISYM_THIS_IMAGE:
+	    case GFC_ISYM_TIME:
+	    case GFC_ISYM_TIME8:
+	    case GFC_ISYM_TTYNAM:
+	    case GFC_ISYM_UMASK:
+	    case GFC_ISYM_UNLINK:
+	      return -2;
 
-	default:
-	  return -2;
+	  default:
+	    break;
+	  }
 	}
 
+    compare_arglists:
+
+      args1 = e1->value.function.actual;
+      args2 = e2->value.function.actual;
+
       /* Compare the argument lists for equality.  */
       while (args1 && args2)
 	{