blob: 04bfada25059ba122bbb7fdff66944f8cb49526f [file] [log] [blame]
Anders Carlsson1f240322009-12-22 05:24:09 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
2template<typename T>
3struct S {
4 S() { }
5};
6
7template<typename T>
8struct vector {
9 void push_back(const T&) { int a[sizeof(T) ? -1: -1]; } // expected-error {{array size is negative}}
10};
11
12class GRExprEngine {
13public:
14 typedef vector<S<void *> >CheckersOrdered;
15 CheckersOrdered Checkers;
16
17 template <typename CHECKER>
18 void registerCheck(CHECKER *check) {
John McCall7c2342d2010-03-10 11:27:22 +000019 Checkers.push_back(S<void *>()); // expected-note {{in instantiation of member function 'vector<S<void *> >::push_back' requested here}}
Anders Carlsson1f240322009-12-22 05:24:09 +000020 }
21};
22
23class RetainReleaseChecker { };
24
25void f(GRExprEngine& Eng) {
John McCall7c2342d2010-03-10 11:27:22 +000026 Eng.registerCheck(new RetainReleaseChecker); // expected-note {{in instantiation of function template specialization 'GRExprEngine::registerCheck<RetainReleaseChecker>' requested here}}
Anders Carlsson1f240322009-12-22 05:24:09 +000027}
John McCallc2233c52010-01-15 08:34:02 +000028
29// PR 5838
30namespace test1 {
31 template<typename T> struct A {
32 int a;
33 };
34
35 template<typename T> struct B : A<float>, A<T> {
36 void f() {
37 a = 0; // should not be ambiguous
38 }
39 };
40 template struct B<int>;
41
42 struct O {
43 int a;
44 template<typename T> struct B : A<T> {
45 void f() {
John McCall110acc12010-04-27 01:43:38 +000046 a = 0; // expected-error {{'test1::O::a' is not a member of class 'test1::O::B<int>'}}
John McCallc2233c52010-01-15 08:34:02 +000047 }
48 };
49 };
50 template struct O::B<int>; // expected-note {{in instantiation}}
51}
John McCall43fed0d2010-11-12 08:19:04 +000052
53// PR7248
54namespace test2 {
55 template <class T> struct A {
56 void foo() {
57 T::bar(); // expected-error {{type 'int' cannot}}
58 }
59 };
60
61 template <class T> class B {
62 void foo(A<T> a) {
63 a.test2::template A<T>::foo(); // expected-note {{in instantiation}}
64 }
65 };
66
67 template class B<int>;
68}