Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/concepts-placeholder3.C

raw
1 // PR c++/96443
2 // { dg-do compile { target c++20 } }
3
4 template <class T, class U> concept same_as = __is_same(T, U);
5
6 auto f(auto x) -> same_as<decltype(x)> auto { return 0; }; // { dg-error "constraints" }
7 void g(auto x) { same_as<decltype(x)> auto y = 0; } // { dg-error "constraints" }
8 auto h(auto x) -> same_as<decltype(x.missing)> auto { return 0; } // { dg-error "constraints|missing" }
9 template <class T, same_as<T> auto N> void i() {}
10
11 int main() {
12 f(0); // { dg-bogus "" }
13 f(true); // { dg-message "required from here" }
14 g(0); // { dg-bogus "" }
15 g(true); // { dg-message "required from here" }
16 h(0); // { dg-message "required from here" }
17 i<int, 0>(); // { dg-bogus "" }
18 i<int, true>(); // { dg-error "no match|constraints" }
19 }