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/30733] New: VOLATILE: Missed optimization - attribute not restricted to scope


+++ This bug was initially created as a clone of Bug #30522 +++

Setting the VOLATILE attribute to a host- or use-associated variable currently
marks the variable everywhere as VOLATILE. The attribute should be, however,
restricted to the scope. (This is a missed optimization only.)

Possible implementation:

decl.c: gfc_match_volatile

        case MATCH_YES:
          /* If the use- or host-associated symbol is not volatile, we
             clone it.  */
          if (!sym->attr.volatile_ && sym->ns != gfc_current_ns)
            {
/* note somewhere that in this namespace VOLATILE is needed, e.g. by cloning
the variable here and setting below the attribute only to the cloned variable.
And then put a check in trans-decl.c in e.g. gfc_generate_function_code near
generate_local_vars to actually mark this variable as volatile; be careful that
the variable should be "external volatile" not a new local variable.
*/
            }

          if (gfc_add_volatile (&sym->attr, sym->name, &gfc_current_locus)

Test case: See PR30522's volatile10.f90 (search for TODO).

Maybe the fact that -fdump-tree-original does not show the VOLATILE attribute
for module variables could be solved as collateral damage.


-- 
           Summary: VOLATILE: Missed optimization - attribute not restricted
                    to scope
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org
 BugsThisDependsOn: 30522


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


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