aboutsummaryrefslogtreecommitdiff
path: root/clang/test/SemaCXX
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaCXX')
-rw-r--r--clang/test/SemaCXX/cxx20-ctad-type-alias.cpp17
-rw-r--r--clang/test/SemaCXX/cxx23-assume.cpp9
-rw-r--r--clang/test/SemaCXX/cxx2b-deducing-this.cpp8
-rw-r--r--clang/test/SemaCXX/cxx2c-fold-exprs.cpp202
-rw-r--r--clang/test/SemaCXX/cxx2c-template-template-param.cpp4
-rw-r--r--clang/test/SemaCXX/invalid-requirement-requires-expr.cpp4
-rw-r--r--clang/test/SemaCXX/overload-resolution-deferred-templates.cpp3
-rw-r--r--clang/test/SemaCXX/type-traits.cpp4
8 files changed, 194 insertions, 57 deletions
diff --git a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
index fd1a5c0..404b928 100644
--- a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
+++ b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
@@ -587,6 +587,23 @@ static_assert(__is_same(decltype(a), A<A<int>>));
} // namespace GH133132
+namespace GH131408 {
+
+struct Node {};
+
+template <class T, Node>
+struct A {
+ A(T) {}
+};
+
+template <class T>
+using AA = A<T, {}>;
+
+AA a{0};
+
+static_assert(__is_same(decltype(a), A<int, Node{}>));
+}
+
namespace GH130604 {
template <typename T> struct A {
A(T);
diff --git a/clang/test/SemaCXX/cxx23-assume.cpp b/clang/test/SemaCXX/cxx23-assume.cpp
index 99a82d9..ce86266 100644
--- a/clang/test/SemaCXX/cxx23-assume.cpp
+++ b/clang/test/SemaCXX/cxx23-assume.cpp
@@ -127,13 +127,12 @@ struct F {
template <typename T>
constexpr int f5() requires C<T> { return 1; } // expected-note {{while checking the satisfaction}}
- // expected-note@-1 {{while substituting template arguments}}
- // expected-note@-2 {{candidate template ignored}}
+ // expected-note@-1 {{candidate template ignored}}
template <typename T>
-constexpr int f5() requires (!C<T>) { return 2; } // expected-note 4 {{while checking the satisfaction}}
- // expected-note@-1 4 {{while substituting template arguments}}
- // expected-note@-2 {{candidate template ignored}}
+constexpr int f5() requires (!C<T>) { return 2; } // expected-note 4 {{while checking the satisfaction}} \
+ // expected-note 4 {{while substituting template arguments}} \
+ // expected-note {{candidate template ignored}}
static_assert(f5<int>() == 1);
static_assert(f5<D>() == 1); // expected-note 3 {{while checking constraint satisfaction}}
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 74b3573..6777dc2 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -1257,13 +1257,13 @@ void f() {
(&A::e)(a, a);
// expected-error@-1 {{no matching function for call to 'e'}} \
// expected-note@#tpl-address-e{{candidate template ignored: constraints not satisfied [with T = A, U = A]}} \
- // expected-note@#tpl-address-e{{because '__is_same(tpl_address::A, int)' evaluated to false}}
+ // expected-note@#tpl-address-e{{because '__is_same(A, int)' evaluated to false}}
(&A::e<A>)(a, 0);
(&A::e<A>)(a, a);
// expected-error@-1 {{no matching function for call to 'e'}} \
// expected-note@#tpl-address-e{{candidate template ignored: constraints not satisfied [with T = A, U = A]}} \
- // expected-note@#tpl-address-e{{because '__is_same(tpl_address::A, int)' evaluated to false}}
+ // expected-note@#tpl-address-e{{because '__is_same(A, int)' evaluated to false}}
(&A::e<A, int>)(a, 0);
@@ -1273,12 +1273,12 @@ void f() {
(&A::f<A>)(a);
// expected-error@-1 {{no matching function for call to 'f'}} \
// expected-note@#tpl-address-f{{candidate template ignored: constraints not satisfied [with T = A]}} \
- // expected-note@#tpl-address-f{{because '__is_same(tpl_address::A, int)' evaluated to false}}
+ // expected-note@#tpl-address-f{{because '__is_same(A, int)' evaluated to false}}
(&A::f)(a);
// expected-error@-1 {{no matching function for call to 'f'}} \
// expected-note@#tpl-address-f{{candidate template ignored: constraints not satisfied [with T = A]}} \
- // expected-note@#tpl-address-f{{because '__is_same(tpl_address::A, int)' evaluated to false}}
+ // expected-note@#tpl-address-f{{because '__is_same(A, int)' evaluated to false}}
(&A::g)(a);
(&A::g)(a, 0);
diff --git a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
index 4220486..137f46e 100644
--- a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
+++ b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -std=c++2c -verify %s
-template <class T> concept A = true;
-template <class T> concept C = A<T> && true;
+template <class T> concept A = (T(), true);
+template <class T> concept C = A<T> && true; // #C
template <class T> concept D = A<T> && __is_same(T, int);
@@ -40,13 +40,23 @@ constexpr int i(T...) { return 1; }; // expected-note {{candidate}}
static_assert(i(0) == 1); // expected-error {{call to 'i' is ambiguous}}
-template <class... T> requires (A<T> || ... || true)
-constexpr int j(T...) { return 0; };
-template <class... T> requires (C<T> && ... && true)
-constexpr int j(T...) { return 1; };
+template <class... T> requires (A<T> || ... || true) constexpr int j(T...) { return 0; }; // #j1
+template <class... T> requires (C<T> && ... && true) constexpr int j(T...) { return 1; }; // #j2
static_assert(j(0) == 1);
+// expected-error@-1 {{call to 'j' is ambiguous}}
+// expected-note@#j1 {{candidate function [with T = <int>]}}
+// expected-note@#j2 {{candidate function [with T = <int>]}}
+// expected-note@#j2 {{imilar constraint expressions not considered equivalent}}
+// expected-note@#j1 {{similar constraint expression here}}
+
+
static_assert(j() == 1);
+// expected-error@-1 {{call to 'j' is ambiguous}}
+// expected-note@#j1 {{candidate function [with T = <>]}}
+// expected-note@#j2 {{candidate function [with T = <>]}}
+// expected-note@#j2 {{imilar constraint expressions not considered equivalent}}
+// expected-note@#j1 {{similar constraint expression here}}
@@ -107,7 +117,7 @@ void test() {
}
namespace substitution {
- struct S {
+struct S {
using type = int;
};
@@ -144,51 +154,69 @@ consteval int Or3() requires (C<typename T::type> || ... || C<typename U::type>)
static_assert(And1<>() == 1);
static_assert(And1<S>() == 1);
static_assert(And1<S, S>() == 1);
+// FIXME: The diagnostics are not so great
static_assert(And1<int>() == 1); // expected-error {{no matching function for call to 'And1'}}
- // expected-note@#and1 {{candidate template ignored: constraints not satisfied}}
- // expected-note@#and1 {{because substituted constraint expression is ill-formed}}
+ // expected-note@#and1 {{candidate template ignored: constraints not satisfied [with T = <int>]}}
+ // expected-note@#and1 {{because 'typename T::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
static_assert(And1<S, int>() == 1); // expected-error {{no matching function for call to 'And1'}}
- // expected-note@#and1 {{candidate template ignored: constraints not satisfied}}
- // expected-note@#and1 {{because substituted constraint expression is ill-formed}}
+ // expected-note@#and1 {{candidate template ignored: constraints not satisfied [with T = <S, int>]}}
+ // expected-note@#and1 {{because 'typename T::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
static_assert(And1<int, S>() == 1); // expected-error {{no matching function for call to 'And1'}}
- // expected-note@#and1 {{candidate template ignored: constraints not satisfied}}
- // expected-note@#and1 {{because substituted constraint expression is ill-formed}}
+ // expected-note@#and1 {{candidate template ignored: constraints not satisfied [with T = <int, S>]}}
+ // expected-note@#and1 {{because 'typename T::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
static_assert(And2<S>() == 2);
static_assert(And2<S, S>() == 2);
-static_assert(And2<int>() == 2);
+static_assert(And2<int>() == 2); // expected-error {{no matching function for call to 'And2'}}
+ // expected-note@#and2 {{candidate template ignored: constraints not satisfied [with T = int, U = <>]}}
+ // expected-note@#and2 {{because 'typename U::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
+
static_assert(And2<int, int>() == 2); // expected-error {{no matching function for call to 'And2'}}
- // expected-note@#and2 {{candidate template ignored: constraints not satisfied}}
- // expected-note@#and2 {{because substituted constraint expression is ill-formed}}
+ // expected-note@#and2 {{candidate template ignored: constraints not satisfied [with T = S, U = <int>]}} \
+ // expected-note@#and2 {{because 'typename U::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
static_assert(And2<S, int>() == 2); // expected-error {{no matching function for call to 'And2'}}
- // expected-note@#and2 {{candidate template ignored: constraints not satisfied}}
- // expected-note@#and2 {{because substituted constraint expression is ill-formed}}
+ // expected-note@#and2 {{candidate template ignored: constraints not satisfied [with T = int, U = <S>]}}
+ // expected-note@#and2 {{because 'typename T::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
static_assert(And2<int, S>() == 2); // expected-error {{no matching function for call to 'And2'}}
- // expected-note@#and2 {{candidate template ignored: constraints not satisfied}}
- // expected-note@#and2 {{because substituted constraint expression is ill-formed}}
+ // expected-note@#and2 {{candidate template ignored: constraints not satisfied [with T = int, U = <int>]}}
+ // expected-note@#and2 {{because 'typename T::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
static_assert(And3<S>() == 3);
static_assert(And3<S, S>() == 3);
static_assert(And3<int>() == 3); // expected-error {{no matching function for call to 'And3'}}
- // expected-note@#and3 {{candidate template ignored: constraints not satisfied}}
- // expected-note@#and3 {{because substituted constraint expression is ill-formed}}
+ // expected-note@#and3 {{candidate template ignored: constraints not satisfied [with T = int, U = <>]}}
+ // expected-note@#and3 {{because 'typename T::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
+
static_assert(And3<int, int>() == 3); // expected-error {{no matching function for call to 'And3'}}
- // expected-note@#and3 {{candidate template ignored: constraints not satisfied}}
- // expected-note@#and3 {{because substituted constraint expression is ill-formed}}
+ // expected-note@#and3 {{candidate template ignored: constraints not satisfied [with T = int, U = <int>]}}
+ // expected-note@#and3 {{because 'typename T::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
+
static_assert(And3<S, int>() == 3); // expected-error {{no matching function for call to 'And3'}}
- // expected-note@#and3 {{candidate template ignored: constraints not satisfied}}
- // expected-note@#and3 {{because substituted constraint expression is ill-formed}}
+ // expected-note@#and3 {{candidate template ignored: constraints not satisfied [with T = S, U = <int>]}}
+ // expected-note@#and3 {{because 'typename U::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
+
static_assert(And3<int, S>() == 3); // expected-error {{no matching function for call to 'And3'}}
- // expected-note@#and3 {{candidate template ignored: constraints not satisfied}}
- // expected-note@#and3 {{because substituted constraint expression is ill-formed}}
+ // expected-note@#and3 {{candidate template ignored: constraints not satisfied [with T = int, U = <S>]}}
+ // expected-note@#and3 {{because 'typename T::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
static_assert(Or1<>() == 1); // expected-error {{no matching function for call to 'Or1'}}
@@ -198,25 +226,26 @@ static_assert(Or1<int, S>() == 1);
static_assert(Or1<S, int>() == 1);
static_assert(Or1<S, S>() == 1);
static_assert(Or1<int>() == 1); // expected-error {{no matching function for call to 'Or1'}}
- // expected-note@#or1 {{candidate template ignored: constraints not satisfied}} \
- // expected-note@#or1 {{because substituted constraint expression is ill-formed}}
-
+ // expected-note@#or1 {{candidate template ignored: constraints not satisfied}}
+ // expected-note@#or1 {{because 'typename T::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
static_assert(Or2<S>() == 2);
static_assert(Or2<int, S>() == 2);
static_assert(Or2<S, int>() == 2);
static_assert(Or2<S, S>() == 2);
static_assert(Or2<int>() == 2); // expected-error {{no matching function for call to 'Or2'}}
- // expected-note@#or2 {{candidate template ignored: constraints not satisfied}} \
- // expected-note@#or2 {{because substituted constraint expression is ill-formed}}
-
+ // expected-note@#or2 {{candidate template ignored: constraints not satisfied [with T = int, U = <>]}}
+ // expected-note@#or2 {{because 'typename T::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
static_assert(Or3<S>() == 3);
static_assert(Or3<int, S>() == 3);
static_assert(Or3<S, int>() == 3);
static_assert(Or3<S, S>() == 3);
static_assert(Or3<int>() == 3); // expected-error {{no matching function for call to 'Or3'}}
- // expected-note@#or3 {{candidate template ignored: constraints not satisfied}} \
- // expected-note@#or3 {{because substituted constraint expression is ill-formed}}
+ // expected-note@#or3 {{candidate template ignored: constraints not satisfied}}
+ // expected-note@#or3 {{because 'typename T::type' does not satisfy 'C'}}
+ // expected-note@#C {{because 'T' does not satisfy 'A'}}
}
namespace bool_conversion_break {
@@ -226,7 +255,7 @@ struct Thingy {
static constexpr int compare(const Thingy&) {return 1;}
};
template <typename ...T, typename ...U>
-void f(A<T ...> *, A<U ...> *) // expected-note {{candidate template ignored: failed template argument deduction}}
+void f(A<T ...> *, A<U ...> *) // expected-note {{candidate template ignored: constraints not satisfied}}
requires (T::compare(U{}) && ...); // expected-error {{atomic constraint must be of type 'bool' (found 'int')}}
void g() {
@@ -269,9 +298,7 @@ struct S {
static_assert(S<int>::f<int>() == 2);
-static_assert(S<int>::g<int>() == 2); // expected-error {{call to 'g' is ambiguous}}
- // expected-note@#nested-ambiguous-g1 {{candidate}}
- // expected-note@#nested-ambiguous-g2 {{candidate}}
+static_assert(S<int>::g<int>() == 2);
}
@@ -384,3 +411,98 @@ struct LazyLitMatrix<index_by<Indices...>, init> {
}
}
+
+namespace GH135190 {
+template <typename T>
+concept A = __is_same_as(T, int) || __is_same_as(T, double) ;
+
+template <typename T>
+concept B = A<T> && __is_same_as(T, double);
+
+template <class... Ts>
+requires(A<Ts> && ...)
+constexpr int g() {
+ return 1;
+}
+
+template <class... Ts>
+requires(B<Ts> && ...)
+constexpr int g() {
+ return 2;
+}
+
+static_assert(g<double>() == 2);
+
+
+template <class... Ts>
+concept all_A = (A<Ts> && ...);
+
+template <class... Ts>
+concept all_B = (B<Ts> && ...);
+
+template <class... Ts>
+requires all_A<Ts...>
+constexpr int h() {
+ return 1;
+}
+
+template <class... Ts>
+requires all_B<Ts...>
+constexpr int h() {
+ return 2;
+}
+
+static_assert(h<double>() == 2);
+}
+
+
+namespace parameter_mapping_regressions {
+
+namespace case1 {
+namespace std {
+template <class _Tp, class... _Args>
+constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...);
+template <class _Tp, class... _Args>
+concept constructible_from = is_constructible_v<_Tp, _Args...>;
+template <class _Tp>
+concept default_initializable = true;
+template <class> using iterator_t = int;
+template <class _Tp>
+concept view = constructible_from<_Tp, _Tp>;
+template <class... _Views>
+ requires(view<_Views> && ...)
+class zip_transform_view;
+} // namespace std
+struct IterDefaultCtrView {};
+template <class... Views>
+using Iter = std::iterator_t<std::zip_transform_view<Views...>>;
+static_assert(
+ std::default_initializable<Iter<IterDefaultCtrView, IterDefaultCtrView>>);
+
+}
+
+namespace case2 {
+
+template <class _Bp>
+constexpr bool False = false;
+
+template <class... _Views>
+concept __zip_all_random_access = (False<_Views> && ...);
+// expected-note@-1 {{evaluated to false}}
+
+template <typename... _Views>
+struct zip_view {
+ void f() requires __zip_all_random_access<_Views...>{};
+ // expected-note@-1 {{because 'int' does not satisfy}}
+};
+
+zip_view<int> test_v;
+static_assert(!__zip_all_random_access<int>);
+
+void test() {
+ test_v.f(); // expected-error {{invalid reference to function 'f'}}
+}
+
+}
+
+}
diff --git a/clang/test/SemaCXX/cxx2c-template-template-param.cpp b/clang/test/SemaCXX/cxx2c-template-template-param.cpp
index ed55a059..4ad3fd9 100644
--- a/clang/test/SemaCXX/cxx2c-template-template-param.cpp
+++ b/clang/test/SemaCXX/cxx2c-template-template-param.cpp
@@ -106,7 +106,7 @@ concept BinaryDefaultedFalse = false;
template <template <typename...> concept C, typename T>
struct S {
- template <C TT> // expected-note {{because 'int' does not satisfy 'UnaryFalse'}}
+ template <C TT> // expected-note 2{{because 'int' does not satisfy 'UnaryFalse'}}
void f(TT); // expected-note {{ignored}}
void g(C auto); // expected-note {{ignored}} \
// expected-note {{because 'int' does not satisfy 'UnaryFalse'}}
@@ -171,7 +171,7 @@ concept BinaryDefaultedFalse = false;
template <template <typename...> concept C, typename T>
struct S {
- template <C TT> // expected-note {{because 'int' does not satisfy 'UnaryFalse'}}
+ template <C TT> // expected-note 2{{because 'int' does not satisfy 'UnaryFalse'}}
void f(TT); // expected-note {{ignored}}
void g(C auto); // expected-note {{ignored}} \
// expected-note {{because 'int' does not satisfy 'UnaryFalse'}}
diff --git a/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp b/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
index 436dfb9..8400340 100644
--- a/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
+++ b/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
@@ -1,6 +1,6 @@
// RUN: %clang -fsyntax-only -std=c++2a -Xclang -verify -ftemplate-depth=5 -ftemplate-backtrace-limit=4 %s
-// RequiresExpr contains invalid requirement. (Eg. Highly recurisive template).
+// RequiresExpr contains invalid requirement. (Eg. Highly recursive template).
template<int x>
struct A { static constexpr bool far(); };
class B {
@@ -19,7 +19,7 @@ constexpr bool A<x>::far() {
// expected-error@#Invalid {{recursive template instantiation exceeded maximum depth}}
// expected-note@#Invalid 3 {{while}}
// expected-note@#Invalid {{contexts in backtrace}}
- // expected-note@#Invalid {{increase recursive template instantiation depth}}
+ // expected-note@#Invalid {{use -ftemplate-depth=N to increase}}
};
}
static_assert(A<1>::far());
diff --git a/clang/test/SemaCXX/overload-resolution-deferred-templates.cpp b/clang/test/SemaCXX/overload-resolution-deferred-templates.cpp
index 135865c..c3bda39 100644
--- a/clang/test/SemaCXX/overload-resolution-deferred-templates.cpp
+++ b/clang/test/SemaCXX/overload-resolution-deferred-templates.cpp
@@ -102,7 +102,7 @@ static_assert(__is_constructible(Movable, int));
// expected-error@-1 {{no matching constructor for initialization of 'Movable'}} \
// expected-note@-1 2{{}}
// expected-error@#err-self-constraint-1{{satisfaction of constraint '__is_constructible(Movable, T)' depends on itself}}
-// expected-note@#err-self-constraint-1 4{{}}
+// expected-note@#err-self-constraint-1 3{{}}
// expected-note@#Movable {{'Movable' defined here}}
template <typename T>
@@ -200,7 +200,6 @@ void h(short n) { f(n); }
// expected-note@-1{{while checking constraint satisfaction for template}}
// expected-note@#GH62096-note1{{in instantiation}}
// expected-note@#GH62096-note1{{while substituting template arguments into constraint expression here}}
-// expected-note@#GH62096-note2{{while substituting template arguments into constraint expression here}}
// expected-note@#GH62096-note2{{while checking the satisfaction of concept}}
// expected-note@#GH62096-err {{expression evaluates}}
}
diff --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp
index d49330f..901d510 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -5129,12 +5129,12 @@ namespace GH121278 {
#if __cplusplus >= 202002L
template <typename B, typename D>
concept C = __is_base_of(B, D);
-// expected-error@-1 {{incomplete type 'GH121278::S' used in type trait expression}}
+// expected-error@-1 {{incomplete type 'S' used in type trait expression}}
// expected-note@-2 {{while substituting template arguments into constraint expression here}}
struct T;
struct S;
bool b = C<T, S>;
-// expected-note@-1 {{while checking the satisfaction of concept 'C<GH121278::T, GH121278::S>' requested here}}
+// expected-note@-1 {{while checking the satisfaction of concept 'C<T, S>' requested here}}
#endif
}