This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: Disallow checking for upper case characters in gfc_match


Daniel Kraft wrote:
while working on parsing of typebound-procedures I just spent some time puzzling over why
gfc_match (" PASS")


What do you think about the attached patch to add an additional "sanity check" to gfc_match resulting in an ICE if a literal character is upper-case? This is very simple, has not much potential to break anything and would have saved me some time if it were already there.
I think it is ok to add a check, however, as match is quite often called and the chance is quite low that this happens:

How about using gcc_assert instead? The result is the same (except that the error message is not as clear) and it is not checked when ENABLE_RUNTIME_CHECKING is disabled. I think it is unlikely to occur in user code, where a better error message is helpful.

Ok to commit with an appropriate ChangeLog entry? Regression testing running on GNU/Linux-x86-32.
Thus: OK to add a gcc_assert.

Tobias

PS: Please CC patches to gcc-patches@.
PPS: s/upper case/lower case not/ or s/Expecting/Unexpected/ in the gfc_internal_error. But this is not needed for gcc_assert ;-)


Index: match.c
===================================================================
--- match.c	(revision 138086)
+++ match.c	(working copy)
@@ -1187,6 +1187,12 @@ loop:
	}

    default:
+
+      /* gfc_next_ascii_char converts characters to lower-case, so we shouldn't
+	 expect an upper case character here!  */
+      if (TOLOWER (c) != c)
+	gfc_internal_error ("gfc_match(): Expecting upper case '%c'", c);
+
      if (c == gfc_next_ascii_char ())
	goto loop;
      break;


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