[PATCH 3/57][Arm][GAS] Add support for MVE instructions: vabs and vneg
[binutils-gdb.git] / gold / testsuite / initpri1.c
blob4d311a25d51f26819e165b7fbcad06def07a5277
1 /* initpri1.c -- test constructor priorities.
3 Copyright (C) 2007-2019 Free Software Foundation, Inc.
4 Copied from the gcc testsuite, where the test was contributed by
5 Mark Mitchell <mark@codesourcery.com>.
7 This file is part of gold.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
24 /* This tests that the linker handles constructor and destructor
25 priorities correctly. */
27 #include <stdlib.h>
29 /* Constructor priorities in attributes were added in gcc 4.3. */
30 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)
32 int i;
33 int j;
35 void c1(void) __attribute__((constructor (500)));
36 void c2(void) __attribute__((constructor (700)));
37 void c3(void) __attribute__((constructor (600)));
39 void c1() {
40 if (i++ != 0)
41 abort ();
44 void c2() {
45 if (i++ != 2)
46 abort ();
49 void c3() {
50 if (i++ != 1)
51 abort ();
54 void d1(void) __attribute__((destructor (500)));
55 void d2(void) __attribute__((destructor (700)));
56 void d3(void) __attribute__((destructor (600)));
58 void d1() {
59 if (--i != 0)
60 abort ();
63 void d2() {
64 if (--i != 2)
65 abort ();
68 void d3() {
69 if (j != 4)
70 abort ();
71 if (--i != 1)
72 abort ();
75 void cd4(void) __attribute__((constructor (800), destructor (800)));
77 void cd4() {
78 if (i != 3)
79 abort ();
80 ++j;
83 void cd5(void) __attribute__((constructor, destructor));
85 void cd5() {
86 if (i != 3)
87 abort();
88 ++j;
91 int main (void) {
92 if (i != 3)
93 return 1;
94 if (j != 2)
95 abort ();
96 return 0;
99 #else /* !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) */
101 int main (void) {
102 exit (0);
105 #endif /* !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) */