From 6e7ff326cfc495b24cb815cc2b539c6bc139c8ea Mon Sep 17 00:00:00 2001
From: Paul Thomas <pault@gcc.gnu.org>
Date: Sat, 17 Jan 2009 09:43:57 +0000
Subject: [PATCH] re PR fortran/38657 (PUBLIC/PRIVATE Common blocks)

2009-01-17  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38657
	* module.c (write_common_0): Revert patch of 2009-01-10.

2009-01-17  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38657
	* gfortran.dg/module_commons_3.f90: Remove

From-SVN: r143459
---
 gcc/fortran/ChangeLog                         |  5 ++
 gcc/fortran/module.c                          |  8 +--
 gcc/testsuite/ChangeLog                       |  5 ++
 .../gfortran.dg/module_commons_3.f90          | 57 -------------------
 4 files changed, 12 insertions(+), 63 deletions(-)
 delete mode 100644 gcc/testsuite/gfortran.dg/module_commons_3.f90

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 6bdcdbf214f1..47f714ee29cd 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,8 @@
+2009-01-17  Paul Thomas  <pault@gcc.gnu.org>
+
+	PR fortran/38657
+	* module.c (write_common_0): Revert patch of 2009-01-05.
+
 2009-01-16  Janus Weil  <janus@gcc.gnu.org>
 
 	PR fortran/38152
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 44ad3758f849..3ae59294f134 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -4337,7 +4337,6 @@ write_common_0 (gfc_symtree *st)
 {
   gfc_common_head *p;
   const char * name;
-  const char * lname;
   int flags;
   const char *label;
   struct written_common *w;
@@ -4350,9 +4349,6 @@ write_common_0 (gfc_symtree *st)
 
   /* We will write out the binding label, or the name if no label given.  */
   name = st->n.common->name;
-
-  /* Use the symtree(local)name to check if the common has been written.  */ 
-  lname = st->name;
   p = st->n.common;
   label = p->is_bind_c ? p->binding_label : p->name;
 
@@ -4360,7 +4356,7 @@ write_common_0 (gfc_symtree *st)
   w = written_commons;
   while (w)
     {
-      int c = strcmp (lname, w->name);
+      int c = strcmp (name, w->name);
       c = (c != 0 ? c : strcmp (label, w->label));
       if (c == 0)
 	write_me = false;
@@ -4388,7 +4384,7 @@ write_common_0 (gfc_symtree *st)
 
       /* Record that we have written this common.  */
       w = XCNEW (struct written_common);
-      w->name = lname;
+      w->name = p->name;
       w->label = label;
       gfc_insert_bbt (&written_commons, w, compare_written_commons);
     }
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a5ba1e6a0fed..fc84ec4446d6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-01-17  Paul Thomas  <pault@gcc.gnu.org>
+
+	PR fortran/38657
+	* gfortran.dg/module_commons_3.f90: Remove
+
 2009-01-16  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* gcc.dg/tree-ssa/foldaddr-1.c: Add the missing '}'.
diff --git a/gcc/testsuite/gfortran.dg/module_commons_3.f90 b/gcc/testsuite/gfortran.dg/module_commons_3.f90
deleted file mode 100644
index 9ae6386e7a86..000000000000
--- a/gcc/testsuite/gfortran.dg/module_commons_3.f90
+++ /dev/null
@@ -1,57 +0,0 @@
-! { dg-do run }
-!
-! PR fortran/38657, in which the mixture of PRIVATE and
-! COMMON in TEST4, would mess up the association with
-! TESTCHAR in TEST2.
-!
-! Contributed by Paul Thomas <pault@gcc.gnu.org>
-! From a report in clf by Chris Bradley.
-!
-MODULE TEST4
-  PRIVATE
-  CHARACTER(LEN=80) :: T1 = &
-    "Mary had a little lamb, Its fleece was white as snow;"
-  CHARACTER(LEN=80) :: T2 = &
-    "And everywhere that Mary went, The lamb was sure to go."
-  CHARACTER(LEN=80) :: TESTCHAR
-  COMMON /TESTCOMMON1/ TESTCHAR
-  PUBLIC T1, T2, FOOBAR
-CONTAINS
-  subroutine FOOBAR (CHECK)
-    CHARACTER(LEN=80) :: CHECK
-    IF (TESTCHAR .NE. CHECK) CALL ABORT
-  end subroutine
-END MODULE TEST4
-
-MODULE TEST3
-  CHARACTER(LEN=80) :: TESTCHAR
-  COMMON /TESTCOMMON1/ TESTCHAR
-END MODULE TEST3
-
-MODULE TEST2
-  use TEST4
-  USE TEST3, chr => testchar
-  PRIVATE
-  CHARACTER(LEN=80) :: TESTCHAR
-  COMMON /TESTCOMMON1/ TESTCHAR
-  PUBLIC TESTCHAR, FOO, BAR, CHR, T1, T2, FOOBAR
-contains
-  subroutine FOO
-    TESTCHAR = T1
-  end subroutine
-  subroutine BAR (CHECK)
-    CHARACTER(LEN=80) :: CHECK
-    IF (TESTCHAR .NE. CHECK) CALL ABORT
-    IF (CHR .NE. CHECK) CALL ABORT
-  end subroutine
-END MODULE TEST2
-
-PROGRAM TEST1
-  USE TEST2
-  call FOO
-  call BAR (T1)
-  TESTCHAR = T2
-  call BAR (T2)
-  CALL FOOBAR (T2)
-END PROGRAM TEST1
-! { dg-final { cleanup-modules "TEST2 TEST3 TEST4" } }
-- 
GitLab