Debian Codegraph @

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

raw
1 // Verify we diagnose an unstable satisfaction result that depends on
2 // completeness of the type A below.
3 //
4 // Like in the previous test, here satisfaction also initially fails,
5 // but this time due to failed substitution into the atom's parameter mapping.
6 //
7 // { dg-do compile { target c++20 } }
8
9 template <class T> concept valid_type = requires { typename T; };
10 // { dg-message "satisfaction of 'valid_type<typename T::type>' .with T = A." "" { target *-*-* } .-1 }
11 // { dg-error "satisfaction value of atomic constraint 'requires.T;. .with T = typename T::type.' changed from 'false' to 'true'" "" { target *-*-* } .-2 }
12
13 template <class T> concept has_mem_type = valid_type<typename T::type>;
14 // { dg-message "satisfaction of 'has_mem_type<T>' .with T = A." "" { target *-*-* } .-1 }
15
16 template <has_mem_type T> int f () { return 0; }
17 template <class T> char f() { return 0; }
18
19 struct A;
20 static_assert (sizeof (f<A>()) == 1); // { dg-message "first evaluated to 'false' from here" }
21 struct A { typedef int type; };
22 static_assert (sizeof (f<A>()) > 1); // { dg-error "assert" }
23 static_assert (sizeof (f<A>()) > 1);