1 // { dg-options -std=c++17 }
2 // Test C++17 selection statements with initializer, basic use.
3 
4 extern int foo (void);
5 extern void bar (int);
6 extern int g;
7 
8 void
f(void)9 f (void)
10 {
11   if (auto p = foo (); p > 10)
12     bar (p);
13   else
14     bar (-p);
15 
16   if ((g += 2); g > 6)
17     bar (1);
18 
19   if (auto a = 9, b = foo (); a + b > 10)
20     bar (a + b);
21   else
22     bar (a - b);
23 
24   if (({ int a; 1;}))
25     bar (0);
26 
27   if (auto i = foo (); i > 6)
28     bar (0);
29   else if (i++; i > 8)
30     bar (1);
31 }
32 
33 extern void lock (void);
34 
35 void
f2(int i)36 f2 (int i)
37 {
38   if (lock (); i > 10)
39     ++i;
40   else
41     --i;
42 }
43 
44 void
f3(int i)45 f3 (int i)
46 {
47   switch (i *= 2; auto idx = i)
48     {
49     case 4:
50       bar (3);
51       break;
52     default:
53       break;
54     }
55 }
56 
57 void
f4(void)58 f4 (void)
59 {
60   if constexpr (constexpr auto s = sizeof (int); s > 10)
61     foo ();
62 }
63