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] PR Detect same values in vector expression subscripts


Hello Thomas,

Thomas Koenig wrote:
this patch yields an error for identical values in vector expression
Regression-tested.  OK for trunk?

+			{
+			  if (n->iterator != NULL)
+			    continue;
+			
+			  en = n->expr;
+			  if (gfc_dep_compare_expr (ec, en) == 0)
+			    {
+			      gfc_error_now ("Elements with the same value at %L"
+					     " and %L in vector subscript"
+					     " in a variable definition"
+					     " context (%s)", &(ec->where),
+					     &(en->where), context);
+			      retval = false;
+
+			      /* Do not issue O(n**2) errors for n occurrences
+				 of the same value. */
+			      break;
+
+			      }
+			  }

Something went wrong with the indentation of the last two lines.

Additionally: How about simply returning with an "return false;"? One error per vector subscript should be sufficient. In my humble opinion, having multiple errors will clutter more the output than helping the user - and in the code one can avoid "retval" which makes the code (nearly undetectably) cleaner.

OK - with fixing the first item and considering the last item.

Thanks for the patch!

Tobias


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