diff mbox

[fortran] Fix an issue found by Coverity scan

Message ID 5058C16D.90208@netcologne.de
State New
Headers show

Commit Message

Thomas Koenig Sept. 18, 2012, 6:46 p.m. UTC
Hello world,

pretty self-explanatory.  No test case because there is no change
in behavior.  OK for trunk?

	Thomas

2012-09-18  Thomas König  <tkoenig@gcc.gnu.org>

         PR fortran/54599
         * dependency.c (gfc_dep_compare_expr):  Clarify logic,
         remove dead code.

Comments

Thomas Koenig Sept. 18, 2012, 8:33 p.m. UTC | #1
Am 18.09.2012 20:46, schrieb Thomas Koenig:
> Hello world,
>
> pretty self-explanatory.  No test case because there is no change
> in behavior.  OK for trunk?

I forgot to add: Regression-tested.

Thomas
Thomas Koenig Sept. 22, 2012, 10:02 a.m. UTC | #2
I wrote:

http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01293.html

> pretty self-explanatory.  No test case because there is no change
> in behavior.  OK for trunk?
Janus Weil Sept. 22, 2012, 10:11 a.m. UTC | #3
Hi Thomas,

> http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01293.html
>
>> pretty self-explanatory.  No test case because there is no change
>> in behavior.  OK for trunk?

looks good to me. Thanks for the patch!

Cheers,
Janus
diff mbox

Patch

Index: dependency.c
===================================================================
--- dependency.c	(Revision 191342)
+++ dependency.c	(Arbeitskopie)
@@ -395,30 +395,21 @@  gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
       l = gfc_dep_compare_expr (e1->value.op.op1, e2->value.op.op1);
       r = gfc_dep_compare_expr (e1->value.op.op2, e2->value.op.op2);
 
-      if (l <= -2)
+      if (l != 0)
 	return l;
 
-      if (l == 0)
-	{
-	  /* Watch out for 'A ' // x vs. 'A' // x.  */
-	  gfc_expr *e1_left = e1->value.op.op1;
-	  gfc_expr *e2_left = e2->value.op.op1;
+      /* Left expressions of // compare equal, but
+	 watch out for 'A ' // x vs. 'A' // x.  */
+      gfc_expr *e1_left = e1->value.op.op1;
+      gfc_expr *e2_left = e2->value.op.op1;
 
-	  if (e1_left->expr_type == EXPR_CONSTANT
-	      && e2_left->expr_type == EXPR_CONSTANT
-	      && e1_left->value.character.length
-		 != e2_left->value.character.length)
-	    return -2;
-	  else
-	    return r;
-	}
+      if (e1_left->expr_type == EXPR_CONSTANT
+	  && e2_left->expr_type == EXPR_CONSTANT
+	  && e1_left->value.character.length
+	  != e2_left->value.character.length)
+	return -2;
       else
-	{
-	  if (l != 0)
-	    return l;
-	  else
-	    return r;
-	}
+	return r;
     }
 
   /* Compare X vs. X-C, for INTEGER only.  */