summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/lto-streamer-in.c5
-rw-r--r--gcc/lto-streamer-out.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/initpri3.c64
5 files changed, 84 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d7ffbef94c8..14d5066fdf0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2011-01-10 Jan Hubicka <jh@suse.cz>
+
+ PR lto/46083
+ * lto-streamer-out.c (pack_ts_function_decl_value_fields): Store
+ DECL_FINI_PRIORITY.
+ * lto-streamer-in.c (unpack_ts_function_decl_value_fields):
+ Restore DECL_FINI_PRIORITY.
+
2011-01-10 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* doc/gimple.texi: Fix quoting of multi-word return values in
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index 4fe9cdb2c6b..ba48cbb3f60 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -1683,6 +1683,11 @@ unpack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
DECL_DISREGARD_INLINE_LIMITS (expr) = (unsigned) bp_unpack_value (bp, 1);
DECL_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
DECL_LOOPING_CONST_OR_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
+ if (DECL_STATIC_DESTRUCTOR (expr))
+ {
+ priority_type p = (priority_type) bp_unpack_value (bp, HOST_BITS_PER_SHORT);
+ SET_DECL_FINI_PRIORITY (expr, p);
+ }
}
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 781b2571c19..82c2f6feae5 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -496,6 +496,8 @@ pack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
bp_pack_value (bp, DECL_DISREGARD_INLINE_LIMITS (expr), 1);
bp_pack_value (bp, DECL_PURE_P (expr), 1);
bp_pack_value (bp, DECL_LOOPING_CONST_OR_PURE_P (expr), 1);
+ if (DECL_STATIC_DESTRUCTOR (expr))
+ bp_pack_value (bp, DECL_FINI_PRIORITY (expr), HOST_BITS_PER_SHORT);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 08241ca719e..6df0d8e0dd9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-01-10 Jan Hubicka <jh@suse.cz>
+
+ PR lto/46083
+ * gcc.dg/initpri3.c: New testcase.
+
2011-01-10 H.J. Lu <hongjiu.lu@intel.com>
PR lto/47222
diff --git a/gcc/testsuite/gcc.dg/initpri3.c b/gcc/testsuite/gcc.dg/initpri3.c
new file mode 100644
index 00000000000..1633da0141f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/initpri3.c
@@ -0,0 +1,64 @@
+/* { dg-do run { target init_priority } } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-flto -O3" } */
+
+extern void abort ();
+
+int i;
+int j;
+
+void c1() __attribute__((constructor (500)));
+void c2() __attribute__((constructor (700)));
+void c3() __attribute__((constructor (600)));
+
+void c1() {
+ if (i++ != 0)
+ abort ();
+}
+
+void c2() {
+ if (i++ != 2)
+ abort ();
+}
+
+void c3() {
+ if (i++ != 1)
+ abort ();
+}
+
+void d1() __attribute__((destructor (500)));
+void d2() __attribute__((destructor (700)));
+void d3() __attribute__((destructor (600)));
+
+void d1() {
+ if (--i != 0)
+ abort ();
+}
+
+void d2() {
+ if (--i != 2)
+ abort ();
+}
+
+void d3() {
+ if (j != 2)
+ abort ();
+ if (--i != 1)
+ abort ();
+}
+
+void cd4() __attribute__((constructor (800), destructor (800)));
+
+void cd4() {
+ if (i != 3)
+ abort ();
+ ++j;
+}
+
+int main () {
+ if (i != 3)
+ return 1;
+ if (j != 1)
+ abort ();
+ return 0;
+}
OpenPOWER on IntegriCloud