]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/39175 (ICE while compiling qt-4.5.0-rc1)
authorBen Elliston <bje@au.ibm.com>
Wed, 25 Mar 2009 22:05:08 +0000 (22:05 +0000)
committerBen Elliston <bje@gcc.gnu.org>
Wed, 25 Mar 2009 22:05:08 +0000 (09:05 +1100)
Backport from mainline:
2009-02-19  Jakub Jelinek  <jakub@redhat.com>

PR target/39175
* c-common.c (c_determine_visibility): If visibility changed and
DECL_RTL has been already set, call make_decl_rtl to update symbol
flags.

cp/
* decl2.c (determine_visibility): If visibility changed and
DECL_RTL has been already set, call make_decl_rtl to update symbol
flags.

testsuite/
* gcc.dg/visibility-20.c: New test.
* g++.dg/ext/visibility/visibility-11.C: New test.

From-SVN: r145076

gcc/ChangeLog
gcc/c-common.c
gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/visibility/visibility-11.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/visibility-20.c [new file with mode: 0644]

index 58d0a7d16977ba0d50de7fbb7170cf8df722048c..4a3c47b4e1e0f991c0a4904357dead94da14bc69 100644 (file)
@@ -1,3 +1,13 @@
+2009-03-26  Ben Elliston  <bje@au.ibm.com>
+
+       Backport from mainline:
+       2009-02-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/39175
+       * c-common.c (c_determine_visibility): If visibility changed and
+       DECL_RTL has been already set, call make_decl_rtl to update symbol
+       flags.
+
 2009-03-24  Ralf Corsépius <ralf.corsepius@rtems.org>
 
        * config/m68k/t-rtems: Add m5329 multilib.
index 4cafe05a0b5c8d1771627746cba90447dc843d99..4b2ee065ad9c9749e2e9e070f8215413ad8552d0 100644 (file)
@@ -1,6 +1,7 @@
 /* Subroutines shared by all languages that are variants of C.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -5768,8 +5769,18 @@ c_determine_visibility (tree decl)
      visibility_specified depending on #pragma GCC visibility.  */
   if (!DECL_VISIBILITY_SPECIFIED (decl))
     {
-      DECL_VISIBILITY (decl) = default_visibility;
-      DECL_VISIBILITY_SPECIFIED (decl) = visibility_options.inpragma;
+      if (visibility_options.inpragma
+         || DECL_VISIBILITY (decl) != default_visibility)
+       {
+         DECL_VISIBILITY (decl) = default_visibility;
+         DECL_VISIBILITY_SPECIFIED (decl) = visibility_options.inpragma;
+         /* If visibility changed and DECL already has DECL_RTL, ensure
+            symbol flags are updated.  */
+         if (((TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
+              || TREE_CODE (decl) == FUNCTION_DECL)
+             && DECL_RTL_SET_P (decl))
+           make_decl_rtl (decl);
+       }
     }
   return false;
 }
index 3c8006ed6c8b2e0163725f12f277291fe2d69657..e7a49cc79d4f86cfdc40e42bed94c545daa398a6 100644 (file)
@@ -1,3 +1,13 @@
+2009-03-26  Ben Elliston  <bje@au.ibm.com>
+
+       Backport from mainline:
+       2009-02-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/39175
+       * decl2.c (determine_visibility): If visibility changed and
+       DECL_RTL has been already set, call make_decl_rtl to update symbol
+       flags.
+
 2009-03-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        Backport from mainline:
index 7feb61aa6e3657db0f366db1b8ab7bca78031f86..67e80e58613bc35dd33ecbdb926ff0c17f0ea855 100644 (file)
@@ -1,6 +1,6 @@
 /* Process declarations and variables for C++ compiler.
    Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Hacked by Michael Tiemann (tiemann@cygnus.com)
 
@@ -1887,6 +1887,8 @@ determine_visibility (tree decl)
 {
   tree class_type = NULL_TREE;
   bool use_template;
+  bool orig_visibility_specified;
+  enum symbol_visibility orig_visibility;
 
   /* Remember that all decls get VISIBILITY_DEFAULT when built.  */
 
@@ -1899,6 +1901,9 @@ determine_visibility (tree decl)
      maybe_clone_body.  */
   gcc_assert (!DECL_CLONED_FUNCTION_P (decl));
 
+  orig_visibility_specified = DECL_VISIBILITY_SPECIFIED (decl);
+  orig_visibility = DECL_VISIBILITY (decl);
+
   if (TREE_CODE (decl) == TYPE_DECL)
     {
       if (CLASS_TYPE_P (TREE_TYPE (decl)))
@@ -2019,6 +2024,15 @@ determine_visibility (tree decl)
          || ! DECL_VISIBILITY_SPECIFIED (decl))
        constrain_visibility (decl, tvis);
     }
+
+  /* If visibility changed and DECL already has DECL_RTL, ensure
+     symbol flags are updated.  */
+  if ((DECL_VISIBILITY (decl) != orig_visibility
+       || DECL_VISIBILITY_SPECIFIED (decl) != orig_visibility_specified)
+      && ((TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
+         || TREE_CODE (decl) == FUNCTION_DECL)
+      && DECL_RTL_SET_P (decl))
+    make_decl_rtl (decl);
 }
 
 /* By default, static data members and function members receive
index 902f8b1d38cbc787efcba35dbbb8ac5663e66b16..0f69e9e947196b1c013a04f035402e3140c67e61 100644 (file)
@@ -1,3 +1,12 @@
+2009-03-26  Ben Elliston  <bje@au.ibm.com>
+
+       Backport from mainline:
+       2009-02-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/39175
+       * gcc.dg/visibility-20.c: New test.
+       * g++.dg/ext/visibility/visibility-11.C: New test.
+
 2009-03-23  Uros Bizjak  <ubizjak@gmail.com>
 
        Backport from mainline:
diff --git a/gcc/testsuite/g++.dg/ext/visibility/visibility-11.C b/gcc/testsuite/g++.dg/ext/visibility/visibility-11.C
new file mode 100644 (file)
index 0000000..78f40c6
--- /dev/null
@@ -0,0 +1,18 @@
+// PR target/39175
+// { dg-do compile }
+// { dg-require-visibility "" }
+// { dg-options "-O2 -fvisibility=hidden -fpic" { target fpic } }
+
+__attribute__((noinline)) int
+foo (int x)
+{
+  return x;
+}
+
+int foo (int x);
+
+int
+bar (int x)
+{
+  return foo (x);
+}
diff --git a/gcc/testsuite/gcc.dg/visibility-20.c b/gcc/testsuite/gcc.dg/visibility-20.c
new file mode 100644 (file)
index 0000000..5fc7447
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR target/39175 */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-options "-O2 -fvisibility=hidden -fpic" { target fpic } } */
+
+__attribute__((noinline)) int
+foo (int x)
+{
+  return x;
+}
+
+int foo (int x);
+
+int
+bar (int x)
+{
+  return foo (x);
+}