aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/ipa/pr70306.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/ipa/pr70306.c')
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pr70306.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/ipa/pr70306.c b/gcc/testsuite/gcc.dg/ipa/pr70306.c
new file mode 100644
index 00000000000..be18208afd4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr70306.c
@@ -0,0 +1,45 @@
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+/* { dg-do run } */
+
+int ctor_counter = 1;
+int dtor_counter;
+
+__attribute__((constructor))
+void A()
+{
+ ctor_counter++;
+}
+
+__attribute__((destructor))
+void B()
+{
+ if (dtor_counter == 0)
+ __builtin_abort ();
+
+ dtor_counter--;
+}
+
+__attribute__((constructor))
+static void C() {
+ ctor_counter++;
+}
+
+__attribute__((destructor))
+static void D() {
+ if (dtor_counter == 0)
+ __builtin_abort ();
+
+ dtor_counter--;
+}
+
+int main()
+{
+ if (ctor_counter != 3)
+ __builtin_abort ();
+
+ dtor_counter = 2;
+
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */