blob: eeb47bdeefa82c6b88efb1fcdaab9533938958de [file] [log] [blame]
// 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-5.c:
* - C++ source code
* - Static destructor
* - GCC destructors using priority
* - GCC init_priority attributes
*
* Expected output and order:
* In AAAA()
* In BBBB()
* In main()
* In bar()
* In baz()
* In foo()
* In ~BBBB()
* In ~AAAA()
*
* :AAAA():BBBB():main():bar():baz():foo():~BBBB():~AAAA()
*/
// 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: :AAAA():BBBB():foo():baz():bar():main():~BBBB():~AAAA()
#include <stdio.h>
struct AAAA {
AAAA() { printf(":AAAA()"); }
~AAAA() { printf(":~AAAA()"); }
};
struct BBBB {
BBBB() { printf(":BBBB()"); }
~BBBB() { printf(":~BBBB()"); }
};
AAAA one __attribute__ ((init_priority(1000)));
BBBB two __attribute__ ((init_priority(2000)));
__attribute__((constructor(3500))) void foo() { printf(":foo()"); }
__attribute__((constructor(5500))) void bar() { printf(":bar()"); }
__attribute__((constructor(4500))) void baz() { printf(":baz()"); }
int main()
{
printf(":main()");
return 0;
}