blob: 9b106f1f21fc5e93ea6dad8ef9aa6fed6a0d46cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// Clang used to crash trying to recover while adding 'this->' before Work(x);
template <typename> struct A {
static void Work(int); // expected-note{{here}}
};
template <typename T> struct B : public A<T> {
template <typename T2> B(T2 x) {
Work(x); // expected-error{{explicit qualification required}}
}
};
void Test() {
B<int> b(0); // expected-note{{in instantiation of function template}}
}
// Don't crash here.
namespace PR16134 {
template <class P> struct S // expected-error {{expected ';'}}
template <> static S<Q>::f() // expected-error +{{}}
}
namespace PR16225 {
template <typename T> void f();
template <typename C> void g(C*) {
struct LocalStruct : UnknownBase<Mumble, C> { }; // expected-error {{use of undeclared identifier 'Mumble'}}
f<LocalStruct>();
#if __cplusplus <= 199711L
// expected-warning@-2 {{template argument uses local type 'LocalStruct'}}
// expected-note@-3 {{while substituting explicitly-specified template arguments}}
#endif
struct LocalStruct2 : UnknownBase<C> { }; // expected-error {{no template named 'UnknownBase'}}
}
struct S;
void h() {
g<S>(0);
#if __cplusplus <= 199711L
// expected-note@-2 {{in instantiation of function template specialization}}
#endif
}
}
namespace test1 {
template <typename> class ArraySlice {};
class Foo;
class NonTemplateClass { // #defined-here
void MemberFunction(ArraySlice<Foo>, int);
template <class T> void MemberFuncTemplate(ArraySlice<T>, int);
};
void NonTemplateClass::MemberFunction(ArraySlice<Foo> resource_data,
int now) {
// expected-note@+1 {{in instantiation of function template specialization 'test1::NonTemplateClass::MemberFuncTemplate<test1::Foo>'}}
MemberFuncTemplate(resource_data, now);
}
template <class T>
void NonTemplateClass::MemberFuncTemplate(ArraySlice<T> resource_data, int) {
// expected-error@+1 {{member 'UndeclaredMethod' used before its declaration}}
UndeclaredMethod(resource_data);
}
// expected-error@+3 {{out-of-line definition of 'UndeclaredMethod' does not match any declaration}}
// expected-note@+2 {{member is declared here}}
// expected-note@#defined-here {{defined here}}
void NonTemplateClass::UndeclaredMethod() {}
}
namespace GH135621 {
template <class T> struct S {};
// expected-note@-1 {{class template declared here}}
template <class T2> void f() {
S<T2>::template S<int>;
// expected-error@-1 {{'S' is expected to be a non-type template, but instantiated to a class template}}
}
template void f<int>();
// expected-note@-1 {{requested here}}
} // namespace GH135621
|