blob: 048d4baf135bf0e8f5c9f806cbbe785e812341cc [file] [log] [blame]
Matt Beaumont-Gay09f34622011-02-25 19:09:01 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor5149f372011-02-25 15:54:31 +00002
3// Note: the formatting in this test case is intentionally funny, with
4// nested-name-specifiers stretched out vertically so that we can
5// match up diagnostics per-line and still verify that we're getting
6// good source-location information.
7
8namespace outer {
9 namespace inner {
10 template<typename T>
11 struct X0 {
12 };
13 }
14}
15
16template<typename T>
17struct add_reference {
18 typedef T& type;
19};
20
21namespace outer_alias = outer;
22
23template<typename T>
24struct UnresolvedUsingValueDeclTester {
25 using outer::inner::X0<
26 typename add_reference<T>::type
27 * // expected-error{{declared as a pointer to a reference of type}}
28 >::value;
29};
30
31UnresolvedUsingValueDeclTester<int> UnresolvedUsingValueDeclCheck; // expected-note{{in instantiation of template class}}
32
33template<typename T>
34struct UnresolvedUsingTypenameDeclTester {
35 using outer::inner::X0<
36 typename add_reference<T>::type
37 * // expected-error{{declared as a pointer to a reference of type}}
38 >::value;
39};
40
41UnresolvedUsingTypenameDeclTester<int> UnresolvedUsingTypenameDeclCheck; // expected-note{{in instantiation of template class}}
42
Douglas Gregorf3db29f2011-02-25 18:19:59 +000043
44template<typename T, typename U>
45struct PseudoDestructorExprTester {
46 void f(T *t) {
47 t->T::template Inner<typename add_reference<U>::type
48 * // expected-error{{as a pointer to a reference of type}}
49 >::Blarg::~Blarg();
50 }
51};
52
53struct HasInnerTemplate {
54 template<typename T>
55 struct Inner;
56
57 typedef HasInnerTemplate T;
58};
59
60void PseudoDestructorExprCheck(
61 PseudoDestructorExprTester<HasInnerTemplate, float> tester) {
62 tester.f(0); // expected-note{{in instantiation of member function}}
63}
Douglas Gregor00cf3cc2011-02-25 20:49:16 +000064
65template<typename T>
66struct DependentScopedDeclRefExpr {
67 void f() {
Douglas Gregor7c3179c2011-02-28 18:50:33 +000068 outer_alias::inner::X0<typename add_reference<T>::type
69 * // expected-error{{as a pointer to a reference of type}}
70 >::value = 17;
Douglas Gregor00cf3cc2011-02-25 20:49:16 +000071 }
72};
Douglas Gregor7c3179c2011-02-28 18:50:33 +000073
74void DependentScopedDeclRefExprCheck(DependentScopedDeclRefExpr<int> t) {
75 t.f(); // expected-note{{in instantiation of member function}}
76}
Douglas Gregor2494dd02011-03-01 01:34:45 +000077
78
79template<typename T>
80struct TypenameTypeTester {
81 typedef typename outer::inner::X0<
82 typename add_reference<T>::type
83 * // expected-error{{declared as a pointer to a reference of type}}
84 >::type type;
85};
86
87TypenameTypeTester<int> TypenameTypeCheck; // expected-note{{in instantiation of template class}}
Douglas Gregor94fdffa2011-03-01 20:11:18 +000088
89template<typename T, typename U>
90struct DependentTemplateSpecializationTypeTester {
91 typedef typename T::template apply<typename add_reference<U>::type
92 * // expected-error{{declared as a pointer to a reference of type}}
93 >::type type;
94};
95
96struct HasApply {
97 template<typename T>
98 struct apply {
99 typedef T type;
100 };
101};
102
103DependentTemplateSpecializationTypeTester<HasApply, int> DTSTCheck; // expected-note{{in instantiation of template class}}
104
105template<typename T, typename U>
106struct DependentTemplateSpecializationTypeTester2 {
107 typedef typename T::template apply<typename add_reference<U>::type
108 * // expected-error{{declared as a pointer to a reference of type}}
109 > type;
110};
111
112DependentTemplateSpecializationTypeTester2<HasApply, int> DTSTCheck2; // expected-note{{in instantiation of template class}}
Douglas Gregor059101f2011-03-02 00:47:37 +0000113
114template<typename T, typename U>
115struct DependentTemplateSpecializationTypeTester3 :
116 T::template apply<typename add_reference<U>::type
117 * // expected-error{{declared as a pointer to a reference of type}}
118 >
119{};
120
121DependentTemplateSpecializationTypeTester3<HasApply, int> DTSTCheck3; // expected-note{{in instantiation of template class}}
122
123template<typename T, typename U>
124struct DependentTemplateSpecializationTypeTester4 {
125 typedef class T::template apply<typename add_reference<U>::type
126 * // expected-error{{declared as a pointer to a reference of type}}
127 > type;
128};
129
130DependentTemplateSpecializationTypeTester4<HasApply, int> DTSTCheck4; // expected-note{{in instantiation of template class}}
Douglas Gregorb6744ef2011-03-02 17:09:35 +0000131
132template<template<class T> class TTP>
133struct AcceptedTemplateTemplateParameter {
134};
135
136template<typename T, typename U>
137struct DependentTemplateTemplateArgumentTester {
138 typedef AcceptedTemplateTemplateParameter<
139 T::
140 template apply<
141 typename add_reference<U>::type
142 * // expected-error{{declared as a pointer to a reference of type}}
143 >::
144 template X>
145 type;
146};
147
148DependentTemplateTemplateArgumentTester<HasApply, int> DTTACheck; // expected-note{{in instantiation of template class}}
Douglas Gregor0f0ea2a2011-03-03 17:04:51 +0000149
150namespace PR9388 {
151 namespace std {
152 template<typename T> class vector {
153 };
154 }
155 template<typename T> static void foo(std::vector<T*> &V) {
156 __PRETTY_FUNCTION__; // expected-warning{{expression result unused}}
157 }
158 void bar(std::vector<int*> &Blocks) {
159 foo(Blocks); // expected-note{{in instantiation of}}
160 }
161
162}