1 // ensure that passing pre/post do not affect constexpr functions
2 // ensure that failing pre/post generate an error at runtime in constexpr funcs
4 // { dg-options "-std=c++20 -fcontracts -fcontract-continuation-mode=on" }
6 constexpr int wfun(int a)
13 constexpr int ffun(int a)
21 constexpr int tfun(T a)
29 constexpr int wtfun(T a)
37 constexpr int ftfun(T a)
44 constexpr int explicitfn(int a)
45 [[ pre ignore: a > 0 ]]
46 [[ pre check_maybe_continue: a > 0 ]]
47 [[ post ignore r: r > 0 ]]
48 [[ post check_maybe_continue r: r > 0 ]]
53 int main(int, char **) {
54 constexpr int a = wfun(10);
56 constexpr int c = wtfun(10);
59 int e = explicitfn(-10);
66 // { dg-skip-if "requires hosted libstdc++ for stdc++exp" { ! hostedlib } }
67 // { dg-output "contract violation in function ffun at .*.C:14: .*(\n|\r\n|\r)" }
68 // { dg-output "contract violation in function ffun at .*.C:15: .*(\n|\r\n|\r)" }
69 // { dg-output "contract violation in function ftfun<int> at .*.C:38: .*(\n|\r\n|\r)" }
70 // { dg-output "contract violation in function ftfun<int> at .*.C:39: .*(\n|\r\n|\r)" }
71 // { dg-output "contract violation in function explicitfn at .*.C:46: .*(\n|\r\n|\r)" }
72 // { dg-output "contract violation in function explicitfn at .*.C:48: .*(\n|\r\n|\r)" }
73 // { dg-output "contract violation in function ftfun<double> at .*.C:38: .*(\n|\r\n|\r)" }
74 // { dg-output "contract violation in function ftfun<double> at .*.C:39: .*(\n|\r\n|\r)" }