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/35037] VOLATILE attribute not being honored with common block variable



------- Comment #3 from fxcoudert at gcc dot gnu dot org  2008-02-01 22:54 -------
I've tried the following "trivial" patch (which should handle both common
blocks and equivalences):

Index: trans-common.c
===================================================================
--- trans-common.c      (revision 131944)
+++ trans-common.c      (working copy)
@@ -678,6 +678,14 @@ create_common (gfc_common_head *com, seg
       /* This is a fake variable just for debugging purposes.  */
       TREE_ASM_WRITTEN (var_decl) = 1;

+      if (s->sym->attr.volatile_)
+       {
+         tree new;
+         TREE_THIS_VOLATILE (var_decl) = 1;
+         new = build_qualified_type (TREE_TYPE (var_decl),
TYPE_QUAL_VOLATILE);
+         TREE_TYPE (var_decl) = new;
+       }
+
       if (com)
        var_decl = pushdecl_top_level (var_decl);
       else


But it looks like it doesn't work. Actually, even without the common block, it
doesn't seem to work:

      subroutine wait4it ()
        logical event
        volatile event
        do
          if (event) exit
        end do
      end subroutine

But I'm useless at reading assembly (the tree dump doesn't have these
attributes written out) and I'm not too sure if the code above is legal, so I'd
be glad for someone to help.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fxcoudert at gcc dot gnu dot
                   |                            |org


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


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