This is the mail archive of the gcc-bugs@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]

[Bug fortran/13249] [gfortran] Error when using COMMON


------- Additional Comments From lei at il dot ibm dot com  2004-05-16 14:23 -------
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 to remove the check.

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

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13249


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