// This file is distributed under the University of Illinois Open Source License. | |
// See LICENSE.TXT for details. | |
/* | |
* | |
* test13-2.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 ~AAAA() | |
* In bar() | |
* In baz() | |
* In foo() | |
* In ~BBBB() | |
* | |
* :BBBB():AAAA():main():~AAAA():bar():baz():foo():~BBBB() | |
*/ | |
// 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: :BBBB():foo():baz():bar():AAAA():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(2250))) void foo() { printf(":foo()"); } | |
__attribute__((constructor(2750))) void bar() { printf(":bar()"); } | |
__attribute__((constructor(2500))) void baz() { printf(":baz()"); } | |
int main() | |
{ | |
printf(":main()"); | |
return 0; | |
} |