From: Tobias Burnus Date: Sat, 13 Nov 2010 17:25:28 +0000 (+0100) Subject: re PR fortran/45742 (VOLATILE has no effect) X-Git-Tag: releases/gcc-4.4.6~267 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eeb185699309f85e5557ac642c9df50259aad827;p=thirdparty%2Fgcc.git re PR fortran/45742 (VOLATILE has no effect) 2010-11-13 Tobias Burnus 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 PR fortran/45742 * gfortran.dg/volatile12.f90: New. From-SVN: r166715 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6ef44f743a02..6e3a475b7e1a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2010-11-13 Tobias Burnus + + 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-10-25 Steven G. Kargl PR fortran/46140 diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c index 92edd208daef..203d802130ec 100644 --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -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; } diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index cc7912f6404e..abcf5f0029bc 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -539,6 +539,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; } @@ -1655,10 +1656,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 (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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 08b992446d26..3aa0ead71c8e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-11-13 Tobias Burnus + + PR fortran/45742 + * gfortran.dg/volatile12.f90: New. + 2010-11-12 Jakub Jelinek Backport from mainline diff --git a/gcc/testsuite/gfortran.dg/volatile12.f90 b/gcc/testsuite/gfortran.dg/volatile12.f90 new file mode 100644 index 000000000000..1e85a2b8edfb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/volatile12.f90 @@ -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" } } +