1 // { dg-do run { target c++17 } }
2 // { dg-options "-Wno-deprecated" }
3 // { dg-require-weak "" }
4 // { dg-additional-sources "inline-var1a.C" }
5 
6 #include "inline-var1.h"
7 
8 static inline int var19 = bar (0);
9 static int inline var20 = bar (1);
10 extern inline int var23;
11 inline int var21 = foo (6);
12 inline int var22 = foo (7);
13 extern inline int var23, var22;
14 inline int var23 = foo (8);
15 
16 static int v, w = 64 + 2;
17 
18 int
foo(int x)19 foo (int x)
20 {
21   if (x != v++)
22     __builtin_abort ();
23   return 36 + x;
24 }
25 
26 int
bar(int x)27 bar (int x)
28 {
29   if (v < 6)
30     __builtin_abort ();
31   if ((x >> 4) != (w >> 4))
32     {
33       if ((x & 15) != 0 || (w & 15) != 2)
34 	__builtin_abort ();
35       w = x + 1;
36     }
37   else if (x != w++)
38     __builtin_abort ();
39   return 46 + x;
40 }
41 
42 int &ref1 = var1;
43 int &ref2 = N::var2;
44 const int &ref3 = S::var3;
45 int &ref4 = S::var4;
46 const int &ref5 = S::var5;
47 const int &ref6 = N::var6;
48 int &ref7 = var7;
49 double &ref8 = N::var8;
50 double &ref9 = S::var9;
51 const int &ref11 = S::var11;
52 int &ref12 = var12;
53 int &ref13 = var13;
54 int &ref14 = U::var14;
55 T &ref15 = U::var15;
56 T &ref16 = U::var16;
57 int &ref17 = U::var17;
58 const double &ref18 = U::var18;
59 int &ref19 = var19;
60 int &ref20 = var20;
61 int &ref21 = var21;
62 int &ref22 = var22;
63 int &ref23 = var23;
64 const int &ref24 = Y<int>::var24;
65 int &ref25 = Y<int>::var25;
66 int &ref26 = Y<int>::var26;
67 int &ref27 = var27<int>;
68 const int &ref28 = Y<int>::var28;
69 const char &ref24a = Y<char>::var24;
70 char &ref25a = Y<char>::var25;
71 int &ref26a = Y<char>::var26;
72 char &ref27a = var27<char>;
73 const char &ref28a = Y<char>::var28;
74 extern int &alt1;
75 extern int &alt2;
76 extern const int &alt3;
77 extern int &alt4;
78 extern const int &alt5;
79 extern const int &alt6;
80 extern int &alt7;
81 extern double &alt8;
82 extern double &alt9;
83 extern const int &alt11;
84 extern int &alt12;
85 extern int &alt13;
86 extern int &alt14;
87 extern T &alt15;
88 extern T &alt16;
89 extern int &alt17;
90 extern const double &alt18;
91 extern int &alt19;
92 extern int &alt20;
93 extern int &alt21;
94 extern int &alt22;
95 extern int &alt23;
96 extern const int &alt24;
97 extern int &alt25;
98 extern int &alt26;
99 extern int &alt27;
100 extern const int &alt28;
101 extern const char &alt24a;
102 extern char &alt25a;
103 extern int &alt26a;
104 extern char &alt27a;
105 extern const char &alt28a;
106 
107 int
main()108 main ()
109 {
110   if (v != 9)
111     __builtin_abort ();
112   if (var1 != 4
113       || N::var2 != 0
114       || S::var3 != 5
115       || S::var4 != 6
116       || S::var5 != 7
117       || N::var6 != 8
118       || var7 != 9
119       || N::var8 != 2.0
120       || S::var9 != 3.0
121       || sizeof (N::var10) != 1
122       || S::var11 != 11
123       || var12 != 36
124       || var13 != 37
125       || U::var14 != 38
126       || U::var15.t != 39
127       || U::var16.t != 40
128       || U::var17 != 41
129       || U::var18 != 4.0
130       || var19 != 46
131       || var20 != 47
132       || var21 != 42
133       || var22 != 43
134       || var23 != 44
135       || Y<int>::var24 != 6
136       || Y<int>::var25 != 7
137       || Y<int>::var26 != 8
138       || var27<int> != 9
139       || Y<int>::var28 != 10
140       || Y<char>::var24 != 6
141       || Y<char>::var25 != 7
142       || Y<char>::var26 != 8
143       || var27<char> != 9
144       || Y<char>::var28 != 10)
145     __builtin_abort ();
146   if (ref1 != 4
147       || ref2 != 0
148       || ref3 != 5
149       || ref4 != 6
150       || ref5 != 7
151       || ref6 != 8
152       || ref7 != 9
153       || alt7 != 9
154       || ref8 != 2.0
155       || alt8 != 2.0
156       || ref9 != 3.0
157       || ref11 != 11
158       || ref12 != 36
159       || ref13 != 37
160       || ref14 != 38
161       || ref15.t != 39
162       || ref16.t != 40
163       || ref17 != 41
164       || ref18 != 4.0
165       || ref19 != 46
166       || alt19 != 62
167       || ref20 != 47
168       || alt20 != 63
169       || ref21 != 42
170       || ref22 != 43
171       || ref23 != 44
172       || ref24 != 6
173       || ref25 != 7
174       || ref26 != 8
175       || ref27 != 9
176       || ref28 != 10
177       || ref24a != 6
178       || ref25a != 7
179       || ref26a != 8
180       || ref27a != 9
181       || ref28a != 10)
182     __builtin_abort ();
183   if (&ref1 != &alt1
184       || &ref2 != &alt2
185       || &ref3 != &alt3
186       || &ref4 != &alt4
187       || &ref5 != &alt5
188       || &ref6 != &alt6
189       || &ref7 == &alt7
190       || &ref8 == &alt8
191       || &ref9 != &alt9
192       || &ref11 != &alt11
193       || &ref12 != &alt12
194       || &ref13 != &alt13
195       || &ref14 != &alt14
196       || &ref15 != &alt15
197       || &ref16 != &alt16
198       || &ref17 != &alt17
199       || &ref18 != &alt18
200       || &ref19 == &alt19
201       || &ref20 == &alt20
202       || &ref21 != &alt21
203       || &ref22 != &alt22
204       || &ref23 != &alt23
205       || &ref24 != &alt24
206       || &ref25 != &alt25
207       || &ref26 != &alt26
208       || &ref27 != &alt27
209       || &ref28 != &alt28
210       || &ref24a != &alt24a
211       || &ref25a != &alt25a
212       || &ref26a != &alt26a
213       || &ref27a != &alt27a
214       || &ref28a != &alt28a)
215     __builtin_abort ();
216 }
217