This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, fortran] PR Detect same values in vector expression subscripts
- From: Tobias Burnus <burnus at net-b dot de>
- To: Thomas Koenig <tkoenig at netcologne dot de>
- Cc: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 28 Jul 2013 18:10:17 +0200
- Subject: Re: [patch, fortran] PR Detect same values in vector expression subscripts
- Newsgroups: gmane.comp.gcc.fortran, gmane.comp.gcc.patches
- References: <51F5154C dot 20604 at netcologne dot de>
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