xref: /llvm-project/clang/test/SemaCXX/invalid-template-base-specifier.cpp (revision da986511fb9da1a46a0ca4dba2e49e2426036303)
1f0084c3bSHaojian Wu // RUN: %clang_cc1 -frecovery-ast -verify %s
2f0084c3bSHaojian Wu 
35f94c9a4SHaojian Wu bool Foo(int *); // expected-note 3{{candidate function not viable}}
4f0084c3bSHaojian Wu 
5f0084c3bSHaojian Wu template <typename T>
6f0084c3bSHaojian Wu struct Crash : decltype(Foo(T())) { // expected-error {{no matching function for call to 'Foo'}}
CrashCrash7f0084c3bSHaojian Wu   Crash(){};
8f0084c3bSHaojian Wu };
9f0084c3bSHaojian Wu 
test()10f0084c3bSHaojian Wu void test() { Crash<int>(); } // expected-note {{in instantiation of template class}}
11bfec030eSHaojian Wu 
12bfec030eSHaojian Wu template <typename T>
13bfec030eSHaojian Wu using Alias = decltype(Foo(T())); // expected-error {{no matching function for call to 'Foo'}}
14bfec030eSHaojian Wu template <typename T>
15*da986511SRichard Smith struct Crash2 : decltype(Alias<T>()) { // expected-note {{in instantiation of template type alias 'Alias' requested here}}
Crash2Crash216bfec030eSHaojian Wu   Crash2(){};
17bfec030eSHaojian Wu };
18bfec030eSHaojian Wu 
test2()19*da986511SRichard Smith void test2() { Crash2<int>(); } // expected-note {{in instantiation of template class 'Crash2<int>' requested here}}
205f94c9a4SHaojian Wu 
215f94c9a4SHaojian Wu template <typename T>
225f94c9a4SHaojian Wu class Base {};
235f94c9a4SHaojian Wu template <typename T>
245f94c9a4SHaojian Wu struct Crash3 : Base<decltype(Foo(T()))> { // expected-error {{no matching function for call to 'Foo'}}
Crash3Crash3255f94c9a4SHaojian Wu   Crash3(){};
265f94c9a4SHaojian Wu };
275f94c9a4SHaojian Wu 
test3()285f94c9a4SHaojian Wu void test3() { Crash3<int>(); } // expected-note {{in instantiation of template class}}
29