Debian Codegraph @

clang/test/SemaTemplate/instantiate-abbreviated-template.cpp

raw
1 // RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
2
3
4 template<typename...>
5 concept C = false; // expected-note 9{{because}}
6
7 template<typename T>
8 struct S {
9 template<typename U>
10 static void foo1(U a, auto b);
11 static void foo2(T a, C<T> auto b);
12 // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}}
13 static void foo3(T a, C<decltype(a)> auto b);
14 // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}}
15 static void foo4(T a, C<decltype(a)> auto b, const C<decltype(b)> auto &&c);
16 // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}}
17 };
18
19 using sf1 = decltype(S<int>::foo1(1, 2));
20 using sf2 = decltype(S<int>::foo2(1, 2)); // expected-error{{no matching function}}
21 using sf3 = decltype(S<int>::foo3(1, 2)); // expected-error{{no matching function}}
22 using sf4 = decltype(S<int>::foo4(1, 2, 3)); // expected-error{{no matching function}}
23
24
25 template<typename... T>
26 struct G {
27 static void foo1(auto a, const C<decltype(a)> auto &&... b);
28 // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}} expected-note@-1 3{{and}}
29 static void foo2(auto a, const C<decltype(a), T> auto &&... b);
30 // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}} expected-note@-1{{and}}
31 };
32
33 using gf1 = decltype(G<int, char>::foo1('a', 1, 2, 3, 4)); // expected-error{{no matching function}}
34 using gf2 = decltype(G<int, char>::foo2('a', 1, 2)); // expected-error{{no matching function}}
35
36
37 // Regression (bug #45102): check that instantiation works where there is no
38 // TemplateTypeParmDecl
39 template <typename T> using id = T;
40
41 template <typename T>
42 constexpr void g() {
43 id<void (T)> f;
44 }
45
46 static_assert((g<int>(), true));