| 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s |
| 3 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s |
| 4 | |
| 5 | // Clang used to crash trying to recover while adding 'this->' before Work(x); |
| 6 | |
| 7 | template <typename> struct A { |
| 8 | static void Work(int); // expected-note{{must qualify identifier}} |
| 9 | }; |
| 10 | |
| 11 | template <typename T> struct B : public A<T> { |
| 12 | template <typename T2> B(T2 x) { |
| 13 | Work(x); // expected-error{{use of undeclared identifier}} |
| 14 | } |
| 15 | }; |
| 16 | |
| 17 | void Test() { |
| 18 | B<int> b(0); // expected-note{{in instantiation of function template}} |
| 19 | } |
| 20 | |
| 21 | |
| 22 | // Don't crash here. |
| 23 | namespace PR16134 { |
| 24 | template <class P> struct S // expected-error {{expected ';'}} |
| 25 | template <> static S<Q>::f() // expected-error +{{}} |
| 26 | } |
| 27 | |
| 28 | namespace PR16225 { |
| 29 | template <typename T> void f(); |
| 30 | template <typename C> void g(C*) { |
| 31 | struct LocalStruct : UnknownBase<Mumble, C> { }; // expected-error {{unknown template name 'UnknownBase'}} \ |
| 32 | // expected-error {{use of undeclared identifier 'Mumble'}} |
| 33 | f<LocalStruct>(); |
| 34 | #if __cplusplus <= 199711L |
| 35 | // expected-warning@-2 {{template argument uses local type 'LocalStruct'}} |
| 36 | #endif |
| 37 | } |
| 38 | struct S; |
| 39 | void h() { |
| 40 | g<S>(0); |
| 41 | #if __cplusplus <= 199711L |
| 42 | // expected-note@-2 {{in instantiation of function template specialization}} |
| 43 | #endif |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | namespace test1 { |
| 48 | template <typename> class ArraySlice {}; |
| 49 | class Foo; |
| 50 | class NonTemplateClass { |
| 51 | void MemberFunction(ArraySlice<Foo>, int); |
| 52 | template <class T> void MemberFuncTemplate(ArraySlice<T>, int); |
| 53 | }; |
| 54 | void NonTemplateClass::MemberFunction(ArraySlice<Foo> resource_data, |
| 55 | int now) { |
| 56 | // expected-note@+1 {{in instantiation of function template specialization 'test1::NonTemplateClass::MemberFuncTemplate<test1::Foo>'}} |
| 57 | MemberFuncTemplate(resource_data, now); |
| 58 | } |
| 59 | template <class T> |
| 60 | void NonTemplateClass::MemberFuncTemplate(ArraySlice<T> resource_data, int) { |
| 61 | // expected-error@+1 {{use of undeclared identifier 'UndeclaredMethod'}} |
| 62 | UndeclaredMethod(resource_data); |
| 63 | } |
| 64 | // expected-error@+2 {{out-of-line definition of 'UndeclaredMethod' does not match any declaration}} |
| 65 | // expected-note@+1 {{must qualify identifier to find this declaration in dependent base class}} |
| 66 | void NonTemplateClass::UndeclaredMethod() {} |
| 67 | } |
| 68 | |