Saar Raz | 67c608a | 2020-01-24 00:43:22 +0200 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++2a -verify %s |
| 2 | // RUN: %clang_cc1 -std=c++2a -verify %s -fno-concept-satisfaction-caching -DNO_CACHE |
Saar Raz | b933d37 | 2020-01-22 02:50:12 +0200 | [diff] [blame] | 3 | // expected-no-diagnostics |
| 4 | |
| 5 | template<typename T> |
| 6 | concept C = (f(T()), true); |
| 7 | |
| 8 | template<typename T> |
| 9 | constexpr bool foo() { return false; } |
| 10 | |
| 11 | template<typename T> |
| 12 | requires (f(T()), true) |
| 13 | constexpr bool foo() requires (f(T()), true) { return true; } |
| 14 | |
| 15 | namespace a { |
| 16 | struct A {}; |
| 17 | void f(A a); |
| 18 | } |
| 19 | |
| 20 | static_assert(C<a::A>); |
| 21 | static_assert(foo<a::A>()); |
| 22 | |
| 23 | namespace a { |
| 24 | // This makes calls to f ambiguous, but the second check will still succeed |
| 25 | // because the constraint satisfaction results are cached. |
| 26 | void f(A a, int = 2); |
| 27 | } |
| 28 | #ifdef NO_CACHE |
| 29 | static_assert(!C<a::A>); |
| 30 | static_assert(!foo<a::A>()); |
| 31 | #else |
| 32 | static_assert(C<a::A>); |
| 33 | static_assert(foo<a::A>()); |
| 34 | #endif |