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] Warning for feal / complex equality / inequality comparisons


Thomas Koenig wrote:
the attached patch warns about comparisions for equality and inequality
of real and complex values if -Wcompare-reals is given. The new
compiler option is included in -Wall.

Regression-tested, tested with "make info" and "make dvi".
OK for trunk?

Thanks for the patch. It's okay, after fixing the nits below.


+	  if (gfc_option.warn_compare_reals)
+	    {
+	      gfc_intrinsic_op op = e->value.op.op;
+	
+	      if ((op1->ts.type == BT_REAL || op1->ts.type == BT_COMPLEX)
+		  && (op == INTRINSIC_EQ || op == INTRINSIC_EQ_OS
+		      || op == INTRINSIC_NE || op == INTRINSIC_NE_OS))
+		{
+		  bool equality;
+
+		  equality = op == INTRINSIC_EQ || op == INTRINSIC_EQ_OS;
+		
+		  /* Type conversion has made sure that the types
+		     of op1 and op2 agree.  */
+		  gfc_warning ("%s comparison for %s at %L",
+			       equality ? "Equality" : "Inequality",
+			       gfc_typename (&op1->ts), &op1->where);

Can you move up the comment before the "(op1->ts.type"? When reading the patch, I stumbled over that, before reading 8 lines later that checking op1 is sufficient.


Additionally, your gfc_warning is rather unfriendly to translators (try yourself to translate it, taking into account that the "Equality" string might be re-used elsewhere). I think it is better to have two separate strings, one for equality and one for inequality.

Tobias


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