diff options
Diffstat (limited to 'final/ABI-Testsuite/test/s3_3_4/section2.xpp')
-rwxr-xr-x | final/ABI-Testsuite/test/s3_3_4/section2.xpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/final/ABI-Testsuite/test/s3_3_4/section2.xpp b/final/ABI-Testsuite/test/s3_3_4/section2.xpp new file mode 100755 index 00000000..489953b3 --- /dev/null +++ b/final/ABI-Testsuite/test/s3_3_4/section2.xpp @@ -0,0 +1,45 @@ +// 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 +// RUN: cxx_compiler -c %s -o %t.o +// RUN: linker %t.o -o %t%exeext +// RUN: runtool %t%exeext | tee %t.out | FileCheck %s + +// CHECK:A() +// CHECK:D() +// CHECK:B() +// CHECK:C() +// CHECK:main() +// CHECK:Test Passed + +#include <stdio.h> + +static int counter = 0; + +#define INCREMENT_COUNTER counter++; +#define DECREMENT_COUNTER counter--; + +struct A { A() { printf("%s()\n", __FUNCTION__); INCREMENT_COUNTER; } }; +struct B { B() { printf("%s()\n", __FUNCTION__); INCREMENT_COUNTER; } }; +struct C { C() { printf("%s()\n", __FUNCTION__); INCREMENT_COUNTER; } }; +struct D { D() { printf("%s()\n", __FUNCTION__); INCREMENT_COUNTER; } }; + +A v01 __attribute__((init_priority(200))); +B v02 __attribute__((init_priority(505))); +C v03; +D v04 __attribute__((init_priority(325))); + +int main() +{ + printf("%s()\n", __FUNCTION__); + DECREMENT_COUNTER; + DECREMENT_COUNTER; + DECREMENT_COUNTER; + DECREMENT_COUNTER; + if(counter == 0) { + printf("Test Passed\n"); + } else { + printf("Test Failed\n"); + } + return 0; +} |