Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaTemplate / instantiate-abbreviated-template.cpp
blob1f2171a25ebb083d965727def184b850b04c9535
1 // RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
3 template<typename...>
4 concept C = false; // expected-note 9{{because}}
6 template<typename T>
7 struct S {
8 template<typename U>
9 static void foo1(U a, auto b);
10 static void foo2(T a, C<T> auto b);
11 // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}}
12 static void foo3(T a, C<decltype(a)> auto b);
13 // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}}
14 static void foo4(T a, C<decltype(a)> auto b, const C<decltype(b)> auto &&c);
15 // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}}
18 using sf1 = decltype(S<int>::foo1(1, 2));
19 using sf2 = decltype(S<int>::foo2(1, 2)); // expected-error{{no matching function}}
20 using sf3 = decltype(S<int>::foo3(1, 2)); // expected-error{{no matching function}}
21 using sf4 = decltype(S<int>::foo4(1, 2, 3)); // expected-error{{no matching function}}
24 template<typename... T>
25 struct G {
26 static void foo1(auto a, const C<decltype(a)> auto &&... b);
27 // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}} expected-note@-1 3{{and}}
28 static void foo2(auto a, const C<decltype(a), T> auto &&... b);
29 // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}} expected-note@-1{{and}}
32 using gf1 = decltype(G<int, char>::foo1('a', 1, 2, 3, 4)); // expected-error{{no matching function}}
33 using gf2 = decltype(G<int, char>::foo2('a', 1, 2)); // expected-error{{no matching function}}
36 // Regression (bug #45102): check that instantiation works where there is no
37 // TemplateTypeParmDecl
38 template <typename T> using id = T;
40 template <typename T>
41 constexpr void g() {
42 id<void (T)> f;
45 static_assert((g<int>(), true));