arm: Support pac_key_* register operand for MRS/MSR in Armv8.1-M Mainline
[binutils-gdb.git] / gold / testsuite / gdb_index_test.cc
blobd013cbe2871c19ac2139aa986d30accc3a836508
1 // gdb_index_test.cc -- a test case for the --gdb-index option.
3 // Copyright (C) 2012-2024 Free Software Foundation, Inc.
4 // Written by Cary Coutant <ccoutant@google.com>.
6 // This file is part of gold.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
23 // This source file defines a number of symbols of different forms
24 // to exercise the DWARF scanner in gold.
26 namespace
28 int c1_count;
29 int c2_count;
32 namespace one
35 enum G
37 G_A,
38 G_B,
39 G_C
42 class c1
44 public:
45 static int count;
47 c1()
48 { ++c1_count; }
50 ~c1()
52 --c1_count;
55 enum E
57 E_A,
58 E_B,
59 E_C,
62 int
63 val()
64 { return E_A; }
67 c1 c1v;
70 namespace two
72 const int ci = 3;
74 template <typename T>
75 class c2
77 public:
78 c2(T t)
79 : t_(t)
81 ++c2_count;
84 ~c2()
85 { --c2_count; }
88 val()
89 { return this->t_; }
91 T t_;
94 c2<int> c2v1(1);
95 c2<double> c2v2(2.0);
96 c2<int const*> c2v3(&ci);
99 enum F
101 F_A,
102 F_B,
106 template <class C>
107 bool
108 check(C* c)
109 { return c->val() == 0; }
111 bool
112 check_enum(int i)
113 { return i > 0; }
115 struct anonymous_union_container {
116 union {
117 struct astruct {
118 int a;
120 int b;
121 } u;
124 anonymous_union_container anonymous_union_var;
126 #ifdef __GNUC__
127 #define ALWAYS_INLINE __attribute__((always_inline))
128 #else
129 #define ALWAYS_INLINE
130 #endif
132 static inline ALWAYS_INLINE int
133 inline_func_1(int i)
134 { return i * 17; }
137 main()
139 F f = F_A;
140 one::G g = one::G_A;
141 check_enum(f);
142 check_enum(g);
143 check(&one::c1v);
144 check(&two::c2v1);
145 check(&two::c2v2);
146 check(&two::c2v3);
147 anonymous_union_var.u.b = inline_func_1(3) - 51;
148 return anonymous_union_var.u.b;