Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/constexpr-123889.C

raw
1 // PR c++/123889
2 // { dg-do compile { target c++11 } }
3
4 template <class T>
5 constexpr int func (T) {
6 // { dg-message "'constexpr int func\\\(T\\\) \\\[with T = int\\\]' is not usable as a 'constexpr' function because:" "" { target c++11_only } .-1 }
7 // { dg-error "body of 'constexpr' function 'constexpr int func\\\(T\\\) \\\[with T = int\\\]' not a return-statement" "" { target c++11_only } .-2 }
8 return 1;
9 return 2;
10 }
11
12 static_assert (func (1) == 1, "");
13 // { dg-error "non-constant condition for static assertion" "" { target c++11_only } .-1 }
14 // { dg-error "'constexpr int func\\\(T\\\) \\\[with T = int\\\]' called in a constant expression" "" { target c++11_only } .-2 }