[PATCH] PR fortran/85138,85996 -- Use private namespace

Steve Kargl sgk@troutmask.apl.washington.edu
Mon Jun 4 15:13:00 GMT 2018


All,

The attach patch fixes a regression introduced by r258347.  In that
revision, an attempt is made to reduce a scalar integer expression
to a constant in a CHARACTER(LEN=...) type declaration.  If successful,
life is good.  If unsuccessful, the original scalar integer expression is
simply saved for later resolution. 

Unfortunately, this created a regression, because an attempt to reduce
the scalar integer expression mucks up the namespace.  In particular,
this occurs for user-defined generic functions with the module procedures
declared after the use of the generic name (see testcases).  Note, this
may actually be invalid Fortran, but I'm not going to try to unravel:

   A variable in a specification expression shall have its
   type and type parameters, if any, specified by a previous
   declaration in the same scoping unit, by the implicit
   typing rules in effect for the scoping unit, or by host
   or use association.

It seems to be a catch-22.  The module procedures should be available
through host association except the generic name is used before the
module procedures are parsed.

The fix is to use a private namespace.  Whether an attempt to
reduce the scalar interger expression is successful or not,
the private namespace is discarded.

Built and regression tested on x86_64-*-freebsd and i586-*-freebsd.
OK to commit?

2018-06-04  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/85138
	PR fortran/85996
	* decl.c (gfc_match_char_spec): Use private namespace in attempt to
	reduce a charlen to a constant.

2018-06-04  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/85138
	PR fortran/85996
	* gfortran.dg/pr85138_1.f90: New test.
	* gfortran.dg/pr85138_2.f90: Ditto.
	* gfortran.dg/pr85996.f90: Ditto.

-- 
Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr85996.diff
Type: text/x-diff
Size: 5787 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20180604/0614a231/attachment.bin>


More information about the Fortran mailing list