[clang][lex] NFCI: Use DirectoryEntryRef in ModuleMap::inferFrameworkModule()
[llvm-project.git] / clang / test / SemaTemplate / recovery-crash.cpp
bloba451d9d108da5d078525a87646f976ee5fa2b703
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
5 // Clang used to crash trying to recover while adding 'this->' before Work(x);
7 template <typename> struct A {
8 static void Work(int); // expected-note{{here}}
9 };
11 template <typename T> struct B : public A<T> {
12 template <typename T2> B(T2 x) {
13 Work(x); // expected-error{{explicit qualification required}}
17 void Test() {
18 B<int> b(0); // expected-note{{in instantiation of function template}}
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 +{{}}
28 namespace PR16225 {
29 template <typename T> void f();
30 template <typename C> void g(C*) {
31 struct LocalStruct : UnknownBase<Mumble, C> { }; // expected-error {{use of undeclared identifier 'Mumble'}}
32 f<LocalStruct>();
33 #if __cplusplus <= 199711L
34 // expected-warning@-2 {{template argument uses local type 'LocalStruct'}}
35 #endif
36 struct LocalStruct2 : UnknownBase<C> { }; // expected-error {{no template named 'UnknownBase'}}
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
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);
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);
59 template <class T>
60 void NonTemplateClass::MemberFuncTemplate(ArraySlice<T> resource_data, int) {
61 // expected-error@+1 {{member 'UndeclaredMethod' used before its declaration}}
62 UndeclaredMethod(resource_data);
64 // expected-error@+2 {{out-of-line definition of 'UndeclaredMethod' does not match any declaration}}
65 // expected-note@+1 {{member is declared here}}
66 void NonTemplateClass::UndeclaredMethod() {}