================ @@ -0,0 +1,194 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s + +namespace A { +template <typename T> +concept C = true; + +template <typename T> +requires C<T> && C<T> +void f() {} + +template <typename T> +requires C<T> && true +void f() {} + +template <> +void f<int>(); +} + +namespace B { +template <typename T> +concept A = true; +template <typename T> +concept B = true; + +template <typename T> +requires (A<T> && B<T>) +constexpr int f() { return 0; } + +template <typename T> +requires (A<T> || B<T>) +constexpr int f() { return 1; } + +static_assert(f<int>() == 0); +} + +namespace GH122581 { +// Test that producing a Conjunctive Normal Form +// does not blow up exponentially. +// i.e, this should terminate reasonably quickly +// within a small memory footprint +template <typename T> concept C0 = true; +template <typename T> concept C1 = true; +template <typename T> concept C2 = true; +template <typename T> concept C3 = true; +template <typename T> concept C4 = true; + +template <typename T> +concept majority5 = + (C0<T> && C1<T> && C2<T>) || + (C0<T> && C1<T> && C3<T>) || + (C0<T> && C1<T> && C4<T>) || + (C0<T> && C2<T> && C3<T>) || + (C0<T> && C2<T> && C4<T>) || + (C0<T> && C3<T> && C4<T>) || + (C1<T> && C2<T> && C3<T>) || + (C1<T> && C2<T> && C4<T>) || + (C1<T> && C3<T> && C4<T>) || + (C2<T> && C3<T> && C4<T>); + +template <typename T>concept Y = C0<T> && majority5<T>; +template <typename T>concept Z = Y<T> && C1<T>; + +constexpr int foo(majority5 auto x) { return 10; } +constexpr int foo(Y auto y) { return 20; } +constexpr int foo(Z auto y) { return 30; } +static_assert(foo(0) == 30); +} + +namespace WhateverThisIs { +template <typename T> concept C0 = true; +template <typename T> concept C1 = true; +template <typename T> concept C2 = true; +template <typename T> concept C3 = true; +template <typename T> concept C4 = true; + +template <typename T> +concept X = + (C0<T> || C1<T> || C2<T>) && + (C0<T> || C1<T> || C3<T>) && + (C0<T> || C1<T> || C4<T>) && + (C0<T> || C2<T> || C3<T>) && + (C0<T> || C2<T> || C4<T>) && + (C0<T> || C3<T> || C4<T>) && + (C1<T> || C2<T> || C3<T>) && + (C1<T> || C2<T> || C4<T>) && + (C1<T> || C3<T> || C4<T>) && + (C2<T> || C3<T> || C4<T>); + +template <typename T>concept Y = C0<T> && X<T>; + +template <typename T>concept Z = Y<T> && C1<T>; + +constexpr int foo(X auto x) { return 10; } +constexpr int foo(Y auto y) { return 20; } +constexpr int foo(Z auto y) { return 30; } + +static_assert(foo(0) == 30); +} + +namespace WAT{ +template<typename T> +concept Z0 = true; + +template<typename T> +concept Z1 = true; + +template<typename T> +concept Z2 = true; + +template<typename T> +concept Z3 = true; + +template<typename T> +concept Z4 = true; + +template<typename T> +concept Z5 = true; + +template<typename T> +concept Z6 = true; + +template<typename T> +concept Z7 = true; + +template<typename T> +concept Z8 = true; + +template<typename T> +concept Z9 = true; + +template <typename T> +concept X = ---------------- cor3ntin wrote:
I added comments / more tests / cleaned the test file https://github.com/llvm/llvm-project/pull/132849 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits