From 9cbf8b4131d0e9668eace15277988e8d9beed8f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20Schl=C3=BCter?= Date: Sun, 11 Jul 2004 01:50:28 +0200 Subject: [PATCH] trans-decl.c (gfc_create_module_variable): Nothing to do if symbol is in common, because we ... fortran/ * trans-decl.c (gfc_create_module_variable): Nothing to do if symbol is in common, because we ... (gfc_generate_module_vars): Call gfc_trans_common. testsuite/ * gfortran.fortran-torture/execute/common_2.f90: Add check for access to common var from module. From-SVN: r84479 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/trans-decl.c | 8 ++++++-- gcc/testsuite/ChangeLog | 5 +++++ .../gfortran.fortran-torture/execute/common_2.f90 | 6 ++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 813e7c0d400..39057f37a15 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2004-07-10 Tobias Schlueter + + * trans-decl.c (gfc_create_module_variable): Nothing to do if + symbol is in common, because we ... + (gfc_generate_module_vars): Call gfc_trans_common. + 2004-07-10 Paul Brook * trans-array.c (gfc_build_null_descriptor): New function. diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index b1b5120e0d0..4dce18afdcc 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1798,8 +1798,9 @@ gfc_create_module_variable (gfc_symbol * sym) && (sym->attr.flavor != FL_PARAMETER || sym->attr.dimension == 0)) return; - /* Don't generate variables from other modules. */ - if (sym->attr.use_assoc) + /* Don't generate variables from other modules. Variables from + COMMONs will already have been generated. */ + if (sym->attr.use_assoc || sym->attr.in_common) return; if (sym->backend_decl) @@ -1867,6 +1868,9 @@ gfc_generate_module_vars (gfc_namespace * ns) /* Check if the frontend left the namespace in a reasonable state. */ assert (ns->proc_name && !ns->proc_name->tlink); + /* Generate COMMON blocks. */ + gfc_trans_common (ns); + /* Create decls for all the module variables. */ gfc_traverse_ns (ns, gfc_create_module_variable); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3d97823ae49..99083c291ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-07-10 Tobias Schlueter + + * gfortran.fortran-torture/execute/common_2.f90: Add check for + access to common var from module. + 2004-07-10 Tobias Schlueter PR fortran/16336 diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/common_2.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/common_2.f90 index fd7f76220f5..8bcdbb87a4f 100644 --- a/gcc/testsuite/gfortran.fortran-torture/execute/common_2.f90 +++ b/gcc/testsuite/gfortran.fortran-torture/execute/common_2.f90 @@ -2,6 +2,10 @@ MODULE bar INTEGER :: I COMMON /X/I +contains +subroutine set_i() +i = 5 +end subroutine set_i END MODULE bar USE bar @@ -11,4 +15,6 @@ j = 1 i = 2 if (j.ne.i) call abort() if (j.ne.2) call abort() +call set_i() +if (j.ne.5) call abort() END -- 2.30.2