diff mbox

[fortran] Fix PR 78021

Message ID 394629cb-40f4-fde1-03e5-fcedb6692eb4@netcologne.de
State New
Headers show

Commit Message

Thomas Koenig Oct. 22, 2016, 12:33 p.m. UTC
Hello world,

this rather self-explanatory patch fixes a problem where two
function invocations with 'c    ' and 'c' as arguments
were considered equal.

Regression-tested.  OK for trunk and 6 and 5 branches?

Regards

	Thomas

2016-10-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/78021
         * gfc_compare_functions:  Strings with different lengths in
         argument lists compare unequal.

2016-10-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/78021
         * gfortran.dg/string_length-3.f90:  New test.
diff mbox

Patch

Index: dependency.c
===================================================================
--- dependency.c	(Revision 240928)
+++ dependency.c	(Arbeitskopie)
@@ -226,10 +226,27 @@  gfc_dep_compare_functions (gfc_expr *e1, gfc_expr
 	  if ((args1->expr == NULL) ^ (args2->expr == NULL))
 	    return -2;
 
-	  if (args1->expr != NULL && args2->expr != NULL
-	      && gfc_dep_compare_expr (args1->expr, args2->expr) != 0)
-	    return -2;
+	  if (args1->expr != NULL && args2->expr != NULL)
+	    {
+	      gfc_expr *e1, *e2;
+	      e1 = args1->expr;
+	      e2 = args2->expr;
 
+	      if (gfc_dep_compare_expr (e1, e2) != 0)
+		return -2;
+
+	      /* Special case: String arguments which compare equal can have
+		 different lengths, which makes them different in calls to
+		 procedures.  */
+	      
+	      if (e1->expr_type == EXPR_CONSTANT
+		  && e1->ts.type == BT_CHARACTER
+		  && e2->expr_type == EXPR_CONSTANT
+		  && e2->ts.type == BT_CHARACTER
+		  && e1->value.character.length != e2->value.character.length)
+		return -2;
+	    }
+
 	  args1 = args1->next;
 	  args2 = args2->next;
 	}