Possible Bug in gfc_match_name() - whitespace is not a delimiter

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Thu Jun 30 17:52:00 GMT 2005


Kevin Nuss wrote:
> I noticed that in gfc_match_name() in the source file match.c,
> gfc_next_char() is used rather than gfc_next_char_literal(). This causes
> things like "abc def ghi" to be scanned as "abcdefghi" while a variable
> name is being looked for. Doesn't seem correct to me. If it is OK, sorry
> to bother you.

Please note the condition on the while loop:
  do
     {
        ...
     }
  while (ISALNUM (c)
	 || c == '_'
	 || (gfc_option.flag_dollar_ok && c == '$'));

and indeed it correctly rejects wrong code of the type you suggested:
[tobi@marktplatz tests]$ cat name.f90
real :: x y z
end
[tobi@marktplatz tests]$ ~/src/gcc-new/build/gcc/f951 name.f90
 In file name.f90:1

real :: x y z
        1
Error: Syntax error in data declaration at (1)

Execution times (seconds)
 TOTAL                 :   0.01             0.00             0.05 529 kB
Extra diagnostic checks enabled; compiler may run slowly.
Configure with --disable-checking to disable checks.
[tobi@marktplatz tests]$

For the record, gfc_next_char_literal vs. gfc_next_char has little to do with
whitespace: successive whitespace is not collapsed by gfc_next_char_literal,
but it's main purpose is to deal correctly with quotation marks, '!'s and line
continuation.

Good to see that there are people looking at gfortran's source code :-)

Thanks,
- Tobi



More information about the Fortran mailing list