tree-optimization/116481 - avoid building function_type[]
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / constexpr-loop8.C
blobbf132f2484e4a49749d585e427df4b7c5bdda959
1 // PR c++/87594
2 // { dg-do compile { target c++14 } }
4 constexpr bool always_false() { return false; }
5 int f() { return 1; }
7 constexpr int
8 fn1()
10   struct empty_range {
11     constexpr int* begin() { return 0; }
12     constexpr int* end() { return 0; }
13   } e;
14   for (auto x : e)
15     f();
16   return 0;
19 constexpr int
20 fn2 ()
22   int a[] = { 1, 2, 3 };
23   for (auto x : a)
24     f(); // { dg-error "call to non-.constexpr. function" }
25   return 0;
28 constexpr int
29 fn3 ()
31   __extension__ int a[] = { };
32   for (auto x : a)
33     f();
34   return 0;
38 void
39 bar ()
41   constexpr int i1 = fn1 ();
42   constexpr int i2 = fn2 (); // { dg-message "in .constexpr. expansion of " }
43   constexpr int i3 = fn3 ();