Bug 34432 - integer(kind=init_expression) function is rejected
integer(kind=init_expression) function is rejected
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.3.0
: P3 normal
: ---
Assigned To: Jerry DeLisle
: rejects-valid
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2007-12-11 13:02 UTC by Tobias Burnus
Modified: 2008-01-12 08:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-12-16 07:07:43


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-12-11 13:02:00 UTC
I believe the following code is valid and it is accepted by NAG f95, ifort and g95. Gfortran rejects it with

   Error: Invalid character in name at (1)


module m
  integer, parameter :: int_t = kind(4)
end module m

integer(kind=(int_t)) function test4()
  use m
  test4 = 1
end function test4


For the following -- extra ")" -- I got a not so helpful error message:

integer(kind=int_t)) function test4()
  use m
  test4 = 1
end function test4
Comment 1 Jerry DeLisle 2007-12-14 02:18:23 UTC
I am testing a patch that adds a gfc_match_parens function that can be used selectively to catch these imbalances and give a useful message.  I am using it for pr34325 a the moment, but it can be used elsewhere.
Comment 2 Tobias Burnus 2007-12-14 14:00:03 UTC
The problem for (...) expressions is:

In match_primary, several gfc_match_* are called, which all return MATCH_NO, until  gfc_match_char ('('), which returns true. (So far so good.)

However, before "gfc_match_char" there is a call to gfc_match_rvalue.
gfc_match_rvalue calls gfc_match_name -- and the latter not only returns MATCH_NO, but also issues

      if (gfc_error_flag_test() == 0)
        gfc_error ("Invalid character in name at %C");

which is at the heart of the problem. Without the call to gfc_error, the program works.

The next question is how to solve this without breaking the diagnostics. I'd assume this affects much more expressions than this one.

I was thinking of a flag (like "bool match_only"), which means that on needs to audit all 37 uses of gfc_match_name.
Comment 3 Jerry DeLisle 2007-12-16 07:07:43 UTC
This one interests me.  I will try.
Comment 4 Jerry DeLisle 2008-01-12 08:37:37 UTC
Subject: Bug 34432

Author: jvdelisle
Date: Sat Jan 12 08:36:52 2008
New Revision: 131488

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131488
Log:
2008-01-12  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/34432
	* match.c (gfc_match_name): Don't error if leading character is a '(',
	just return MATCH_NO.

Modified:
    trunk/gcc/fortran/ChangeLog

Comment 5 Jerry DeLisle 2008-01-12 08:48:11 UTC
Subject: Bug 34432

Author: jvdelisle
Date: Sat Jan 12 08:47:27 2008
New Revision: 131489

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131489
Log:
2008-01-12  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/34432
	* gfortran.dg/parens_7.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/parens_7.f90
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 6 Jerry DeLisle 2008-01-12 08:49:07 UTC
Fixed on trunk.