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]

[gfortran] PATCH Fix PR 19936


Gfortran issues an interest error message for the
following:

program main
  integer, parameter :: i=4
  print *,(/(i,i=1,4)/)
end program main
$ gfortran implied_parameter.f90
 In file implied_parameter.f90:3

  print *,(/(i,i=1,4)/)
               1
Error: Syntax error in COMPLEX constant at (1)

The problem is that the matcher match_complex_constant() is
run before the matcher for implied do-loops.  The matcher
essentially sees (/ (4,4=1,4) /) after the parameter statement
is used.  The sequence "(4,4" is matched to a complex constant
and the matcher is expecting a closing ")", which of course
is not found and hence the error message.

The attached patch gives the implied do-loop matcher a 
chance to run, and hence issue a much saner error message.

kargl[237] gfc -o ba ba.f90
 In file ba.f90:3

  print *,(/(i,i=1,4)/)
               1
Error: Expected VARIABLE at (1)

The case of a mangled complex constant is still caught.
kargl[237] cat bc.f90
program bc
  complex z
  z = (1,4z)
  print *, z
end program bc
kargl[240] gfc -o z bc.f90
 In file bc.f90:3

  z = (1,4z)
         1
Error: Syntax error in COMPLEX constant at (1)

There is minor exception, but a sensible error message is still
emitted.

kargl[238] cat bc.f90
program bc
  complex z
  z = (1,4=)
  print *, z
end program bc
kargl[239] gfc -o z bc.f90
 In file bc.f90:3

  z = (1,4=)
 1
Error: Unclassifiable statement at (1)


2005-02-13  Steven G. Kargl  <kargls@comcast.net>

      PR 19936
      * primary.c (match_complex_constant): Mangled complex constant may
      be an implied do-loop.  Give implied do-loop matcher a chance.
-- 
Steve

Attachment: pr19936.diff
Description: Text document


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