aboutsummaryrefslogtreecommitdiff
path: root/final/ABI-Testsuite/test/s3_3_4/test13.xpp
diff options
context:
space:
mode:
Diffstat (limited to 'final/ABI-Testsuite/test/s3_3_4/test13.xpp')
-rwxr-xr-xfinal/ABI-Testsuite/test/s3_3_4/test13.xpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/final/ABI-Testsuite/test/s3_3_4/test13.xpp b/final/ABI-Testsuite/test/s3_3_4/test13.xpp
new file mode 100755
index 00000000..52918136
--- /dev/null
+++ b/final/ABI-Testsuite/test/s3_3_4/test13.xpp
@@ -0,0 +1,56 @@
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+/*
+ *
+ * test13.c:
+ * - C++ source code
+ * - Static destructor
+ * - GCC destructors using priority
+ * - GCC init_priority attributes
+ *
+ * Expected output and order:
+ * In BBBB()
+ * In AAAA()
+ * In main()
+ * In bar()
+ * In ~AAAA()
+ * In baz()
+ * In ~BBBB()
+ * In foo()
+ *
+ * :BBBB():AAAA():main():bar():~AAAA():baz():~BBBB():foo()
+ */
+
+// RUN: cxx_compiler %s -c -o %t.o
+// RUN: linker %t.o -o %t%exeext
+// RUN: runtool %t%exeext | tee %t.out | FileCheck %s
+
+// CHECK: :foo():BBBB():baz():AAAA():bar():main():~AAAA():~BBBB()
+
+#include <stdio.h>
+
+struct AAAA {
+ AAAA() { printf(":AAAA()"); }
+ ~AAAA() { printf(":~AAAA()"); }
+};
+
+struct BBBB {
+ BBBB() { printf(":BBBB()"); }
+ ~BBBB() { printf(":~BBBB()"); }
+};
+
+AAAA one __attribute__ ((init_priority(3000)));
+BBBB two __attribute__ ((init_priority(2000)));
+
+__attribute__((constructor(1500))) void foo() { printf(":foo()"); }
+
+__attribute__((constructor(3500))) void bar() { printf(":bar()"); }
+
+__attribute__((constructor(2500))) void baz() { printf(":baz()"); }
+
+int main()
+{
+ printf(":main()");
+ return 0;
+}