]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/45742 (VOLATILE has no effect)
authorTobias Burnus <burnus@net-b.de>
Sat, 13 Nov 2010 17:23:49 +0000 (18:23 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Sat, 13 Nov 2010 17:23:49 +0000 (18:23 +0100)
2010-11-13  Tobias Burnus  <burnus@net-b.de>

        PR fortran/45742
        * trans-common.c (build_field): Add TREE_SIDE_EFFECTS for
        * volatile.
        * trans-decl.c (gfc_finish_var_decl): Ditto.
        (create_function_arglist): Handle volatile dummy arguments.

2010-11-13  Tobias Burnus  <burnus@net-b.de>

        PR fortran/45742
        * gfortran.dg/volatile12.f90: New.

From-SVN: r166714

gcc/fortran/ChangeLog
gcc/fortran/trans-common.c
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/volatile12.f90 [new file with mode: 0644]

index 62d49f4b5f0bd5dfdb9554ce9040c42b8d7043e9..a3cf29466be677f545d5008a73547cc5ca04c5d8 100644 (file)
@@ -1,3 +1,10 @@
+2010-11-13  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/45742
+       * trans-common.c (build_field): Add TREE_SIDE_EFFECTS for volatile.
+       * trans-decl.c (gfc_finish_var_decl): Ditto.
+       (create_function_arglist): Handle volatile dummy arguments.
+
 2010-11-01  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/46152
index 844ac1d26745f97b7cd1bd66f1a40000411d06e0..21abde3397d9b6646d3d57a3fcd97ba3032adefd 100644 (file)
@@ -323,6 +323,7 @@ build_field (segment_info *h, tree union_type, record_layout_info rli)
     {
       tree new_type;
       TREE_THIS_VOLATILE (field) = 1;
+      TREE_SIDE_EFFECTS (field) = 1;
       new_type = build_qualified_type (TREE_TYPE (field), TYPE_QUAL_VOLATILE);
       TREE_TYPE (field) = new_type;
     }
index 88f199ab7fedd963fb434e30dfd8a321f62a3312..03c290af1c2e2d546ff1ffaca4ad9fff6a52e5ce 100644 (file)
@@ -574,6 +574,7 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
   if (sym->attr.volatile_)
     {
       TREE_THIS_VOLATILE (decl) = 1;
+      TREE_SIDE_EFFECTS (decl) = 1;
       new_type = build_qualified_type (TREE_TYPE (decl), TYPE_QUAL_VOLATILE);
       TREE_TYPE (decl) = new_type;
     } 
@@ -1869,10 +1870,19 @@ create_function_arglist (gfc_symbol * sym)
       if (f->sym->attr.proc_pointer)
         type = build_pointer_type (type);
 
+      if (f->sym->attr.volatile_)
+       type = build_qualified_type (type, TYPE_QUAL_VOLATILE);
+
       /* Build the argument declaration.  */
       parm = build_decl (input_location,
                         PARM_DECL, gfc_sym_identifier (f->sym), type);
 
+      if (f->sym->attr.volatile_)
+       {
+         TREE_THIS_VOLATILE (parm) = 1;
+         TREE_SIDE_EFFECTS (parm) = 1;
+       }
+
       /* Fill in arg stuff.  */
       DECL_CONTEXT (parm) = fndecl;
       DECL_ARG_TYPE (parm) = TREE_VALUE (typelist);
index c69219935c9c414e0be7903bd85524381d2a5557..59867e3b682a890ae174a656b38e7db5c6184132 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-13  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/45742
+       * gfortran.dg/volatile12.f90: New.
+
 2010-11-12  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/46177
diff --git a/gcc/testsuite/gfortran.dg/volatile12.f90 b/gcc/testsuite/gfortran.dg/volatile12.f90
new file mode 100644 (file)
index 0000000..1e85a2b
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-optimized -O3" }
+!
+! PR fortran/45742
+!
+
+subroutine sub(arg)
+  integer, volatile :: arg
+  if (arg /= arg) call I_dont_exist()
+end
+
+! { dg-final { scan-tree-dump "integer.kind=.. . volatile arg" "optimized" } }
+! { dg-final { scan-tree-dump-times " =.v. arg;" 2 "optimized" } }
+! { dg-final { scan-tree-dump "i_dont_exist" "optimized" } }
+! { dg-final { cleanup-tree-dump "optimized" } }
+