c++: robustify testcase [PR109752]
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / constexpr-88983.C
blob9d70601d4277c50a1ebb1a92ea3b122bd2dd1c8b
1 // PR c++/88983
2 // { dg-do compile { target c++14 } }
4 constexpr int
5 fn1 (int ay)
7   switch (ay)
8     {
9       if (1)
10         {
11           case 1:
12             return 1;
13         }
14       else
15         {
16           default:;
17         }
18     }
20   return 0;
23 constexpr int
24 fn2 (int ay)
26   switch (ay)
27     {
28       if (1)
29         {
30           case 1:
31             break;
32         }
33       else
34         {
35           default:;
36         }
37     }
39   return 0;
42 constexpr int
43 fn3 (int ay)
45   int i = 0;
46   while (i++ < 100)
47     {
48       if (i == 1)
49         return 1;
50       switch (ay)
51         {
52           if (1)
53             {
54               case 1:
55                 continue;
56             }
57           else
58             {
59               default:;
60               return -1;
61             }
62         }
63       return -1;
64     }
66   return -1;
69 static_assert (fn1 (1) == 1, "");
70 static_assert (fn2 (1) == 0, "");
71 static_assert (fn3 (1) == 1, "");