Proposed patch to 13249

Victor Leikehman lei@haifasphere.co.il
Sun May 16 14:18:00 GMT 2004


Submitted to everybody's review and critique.

PROBLEM DESCRIPTION
===================

A variable that is both defined in a module, and used as common
block name,  triggers error message "Cannot change attributes of
USE-associated symbol".  For example, the following (valid) code
is rejected:

  MODULE MOD
  INTEGER FOO
  END
  PROGRAM MAIN
  USE MOD
  COMMON /FOO/ BAR
  END

This pattern is common in some spec benchmarks.  For comparison,
the following (also valid) code is accepted:

  PROGRAM MAIN
  INTEGER FOO
  COMMON /FOO/ BAR
  END

ANALYSIS
========

Function gfc_add_common, in file symbol.c, says:

gfc_add_common (symbol_attribute * attr, locus * where)
{
  if (check_used (attr, where) || check_done (attr, where))
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return FAILURE;

  attr->common = 1;
  return check_conflict (attr, where);
}

The call to check_used() checks the "use" attribute, which
is 1 for variables defined in modules.  I can't understand
why this check is necessary.  Removing the call to check_used
apparently fixes the problem and does not cause regressions,
BUT I guess it is there for a purpose...

If nobody can see why this check is needed, I will submit the
patch.

	Victor
--
  Victor Leikehman
  IBM Research Labs in Haifa, Israel



More information about the Fortran mailing list