aboutsummaryrefslogtreecommitdiff
path: root/clang/test/SemaTemplate/explicit-instantiation-cxx20.cpp
blob: 33500baf1e37b10704d7e72c225e60d9bd8e1ae1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20  %s

template<class T>
concept C = true;

template<class T>
concept D = C<T> && true;

template<typename T>
struct a {
    void no_candidate() requires(false) {}
    // expected-note@-1 {{candidate function not viable: constraints not satisfied}} \
    // expected-note@-1 {{because 'false' evaluated to false}}
    void no_candidate() requires(false && false) {}
    // expected-note@-1 {{candidate function not viable: constraints not satisfied}} \
    // expected-note@-1 {{because 'false' evaluated to false}}

    void subsumes();
    void subsumes() requires C<T>;
    void subsumes() requires D<T> {};

    void ok() requires false;
    void ok() requires true {};

    void ok2() requires false;
    void ok2(){};

    void ambiguous() requires true;
    // expected-note@-1 {{candidate function}}
    void ambiguous() requires C<T>;
    // expected-note@-1 {{candidate function}}
};
template void a<int>::no_candidate();
// expected-error@-1 {{no viable candidate for explicit instantiation of 'no_candidate'}}

template void a<int>::ambiguous();
// expected-error@-1 {{partial ordering for explicit instantiation of 'ambiguous' is ambiguous}}

template void a<int>::ok();
template void a<int>::ok2();