1 // PR c++/53792 - [C++11] improving compiler-time constexpr evaluation
2 //     Test case from comment #8.
3 // { dg-do compile { target c++14 } }
4 // { dg-additional-options "-O1 -fdump-tree-optimized" }
5 
6 template <class T>
7 void sink (T);
8 
foo()9 constexpr unsigned foo ()
10 {
11   unsigned  i = 1;
12   while ((i << 1) > i)
13     i = i << 1;
14 
15   return i;
16 }
17 
18 template <unsigned N>
19 struct S { };
20 
bar()21 void bar ()
22 {
23   sink (foo ());
24   sink (S<foo ()>());
25 }
26 
27 // Verify that the call to the foo() constexpr function is inlined
28 // regardless of whether or not it's invoked in a constant expression.
29 // { dg-final { scan-tree-dump-not "= *foo *\\\(" "optimized" } }
30