annotate clang/test/SemaCXX/nested-name-spec-locations.cpp @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // Note: the formatting in this test case is intentionally funny, with
anatofuz
parents:
diff changeset
4 // nested-name-specifiers stretched out vertically so that we can
anatofuz
parents:
diff changeset
5 // match up diagnostics per-line and still verify that we're getting
anatofuz
parents:
diff changeset
6 // good source-location information.
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 namespace outer {
anatofuz
parents:
diff changeset
9 namespace inner {
anatofuz
parents:
diff changeset
10 template<typename T>
anatofuz
parents:
diff changeset
11 struct X0 {
anatofuz
parents:
diff changeset
12 };
anatofuz
parents:
diff changeset
13 }
anatofuz
parents:
diff changeset
14 }
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 template<typename T>
anatofuz
parents:
diff changeset
17 struct add_reference {
anatofuz
parents:
diff changeset
18 typedef T& type;
anatofuz
parents:
diff changeset
19 };
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 namespace outer_alias = outer;
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 template<typename T>
anatofuz
parents:
diff changeset
24 struct UnresolvedUsingValueDeclTester {
anatofuz
parents:
diff changeset
25 using outer::inner::X0<
anatofuz
parents:
diff changeset
26 typename add_reference<T>::type
anatofuz
parents:
diff changeset
27 * // expected-error{{declared as a pointer to a reference of type}}
anatofuz
parents:
diff changeset
28 >::value;
anatofuz
parents:
diff changeset
29 };
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 UnresolvedUsingValueDeclTester<int> UnresolvedUsingValueDeclCheck; // expected-note{{in instantiation of template class}}
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 template<typename T>
anatofuz
parents:
diff changeset
34 struct UnresolvedUsingTypenameDeclTester {
anatofuz
parents:
diff changeset
35 using outer::inner::X0<
anatofuz
parents:
diff changeset
36 typename add_reference<T>::type
anatofuz
parents:
diff changeset
37 * // expected-error{{declared as a pointer to a reference of type}}
anatofuz
parents:
diff changeset
38 >::value;
anatofuz
parents:
diff changeset
39 };
anatofuz
parents:
diff changeset
40
anatofuz
parents:
diff changeset
41 UnresolvedUsingTypenameDeclTester<int> UnresolvedUsingTypenameDeclCheck; // expected-note{{in instantiation of template class}}
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 template<typename T, typename U>
anatofuz
parents:
diff changeset
45 struct PseudoDestructorExprTester {
anatofuz
parents:
diff changeset
46 void f(T *t) {
anatofuz
parents:
diff changeset
47 t->T::template Inner<typename add_reference<U>::type
anatofuz
parents:
diff changeset
48 * // expected-error{{as a pointer to a reference of type}}
anatofuz
parents:
diff changeset
49 >::Blarg::~Blarg();
anatofuz
parents:
diff changeset
50 }
anatofuz
parents:
diff changeset
51 };
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 struct HasInnerTemplate {
anatofuz
parents:
diff changeset
54 template<typename T>
anatofuz
parents:
diff changeset
55 struct Inner;
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 typedef HasInnerTemplate T;
anatofuz
parents:
diff changeset
58 };
anatofuz
parents:
diff changeset
59
anatofuz
parents:
diff changeset
60 void PseudoDestructorExprCheck(
anatofuz
parents:
diff changeset
61 PseudoDestructorExprTester<HasInnerTemplate, float> tester) {
anatofuz
parents:
diff changeset
62 tester.f(0); // expected-note{{in instantiation of member function}}
anatofuz
parents:
diff changeset
63 }
anatofuz
parents:
diff changeset
64
anatofuz
parents:
diff changeset
65 template<typename T>
anatofuz
parents:
diff changeset
66 struct DependentScopedDeclRefExpr {
anatofuz
parents:
diff changeset
67 void f() {
anatofuz
parents:
diff changeset
68 outer_alias::inner::X0<typename add_reference<T>::type
anatofuz
parents:
diff changeset
69 * // expected-error{{as a pointer to a reference of type}}
anatofuz
parents:
diff changeset
70 >::value = 17;
anatofuz
parents:
diff changeset
71 }
anatofuz
parents:
diff changeset
72 };
anatofuz
parents:
diff changeset
73
anatofuz
parents:
diff changeset
74 void DependentScopedDeclRefExprCheck(DependentScopedDeclRefExpr<int> t) {
anatofuz
parents:
diff changeset
75 t.f(); // expected-note{{in instantiation of member function}}
anatofuz
parents:
diff changeset
76 }
anatofuz
parents:
diff changeset
77
anatofuz
parents:
diff changeset
78
anatofuz
parents:
diff changeset
79 template<typename T>
anatofuz
parents:
diff changeset
80 struct TypenameTypeTester {
anatofuz
parents:
diff changeset
81 typedef typename outer::inner::X0<
anatofuz
parents:
diff changeset
82 typename add_reference<T>::type
anatofuz
parents:
diff changeset
83 * // expected-error{{declared as a pointer to a reference of type}}
anatofuz
parents:
diff changeset
84 >::type type;
anatofuz
parents:
diff changeset
85 };
anatofuz
parents:
diff changeset
86
anatofuz
parents:
diff changeset
87 TypenameTypeTester<int> TypenameTypeCheck; // expected-note{{in instantiation of template class}}
anatofuz
parents:
diff changeset
88
anatofuz
parents:
diff changeset
89 template<typename T, typename U>
anatofuz
parents:
diff changeset
90 struct DependentTemplateSpecializationTypeTester {
anatofuz
parents:
diff changeset
91 typedef typename T::template apply<typename add_reference<U>::type
anatofuz
parents:
diff changeset
92 * // expected-error{{declared as a pointer to a reference of type}}
anatofuz
parents:
diff changeset
93 >::type type;
anatofuz
parents:
diff changeset
94 };
anatofuz
parents:
diff changeset
95
anatofuz
parents:
diff changeset
96 struct HasApply {
anatofuz
parents:
diff changeset
97 template<typename T>
anatofuz
parents:
diff changeset
98 struct apply {
anatofuz
parents:
diff changeset
99 typedef T type;
anatofuz
parents:
diff changeset
100 };
anatofuz
parents:
diff changeset
101 };
anatofuz
parents:
diff changeset
102
anatofuz
parents:
diff changeset
103 DependentTemplateSpecializationTypeTester<HasApply, int> DTSTCheck; // expected-note{{in instantiation of template class}}
anatofuz
parents:
diff changeset
104
anatofuz
parents:
diff changeset
105 template<typename T, typename U>
anatofuz
parents:
diff changeset
106 struct DependentTemplateSpecializationTypeTester2 {
anatofuz
parents:
diff changeset
107 typedef typename T::template apply<typename add_reference<U>::type
anatofuz
parents:
diff changeset
108 * // expected-error{{declared as a pointer to a reference of type}}
anatofuz
parents:
diff changeset
109 > type;
anatofuz
parents:
diff changeset
110 };
anatofuz
parents:
diff changeset
111
anatofuz
parents:
diff changeset
112 DependentTemplateSpecializationTypeTester2<HasApply, int> DTSTCheck2; // expected-note{{in instantiation of template class}}
anatofuz
parents:
diff changeset
113
anatofuz
parents:
diff changeset
114 template<typename T, typename U>
anatofuz
parents:
diff changeset
115 struct DependentTemplateSpecializationTypeTester3 :
anatofuz
parents:
diff changeset
116 T::template apply<typename add_reference<U>::type
anatofuz
parents:
diff changeset
117 * // expected-error{{declared as a pointer to a reference of type}}
anatofuz
parents:
diff changeset
118 >
anatofuz
parents:
diff changeset
119 {};
anatofuz
parents:
diff changeset
120
anatofuz
parents:
diff changeset
121 DependentTemplateSpecializationTypeTester3<HasApply, int> DTSTCheck3; // expected-note{{in instantiation of template class}}
anatofuz
parents:
diff changeset
122
anatofuz
parents:
diff changeset
123 template<typename T, typename U>
anatofuz
parents:
diff changeset
124 struct DependentTemplateSpecializationTypeTester4 {
anatofuz
parents:
diff changeset
125 typedef class T::template apply<typename add_reference<U>::type
anatofuz
parents:
diff changeset
126 * // expected-error{{declared as a pointer to a reference of type}}
anatofuz
parents:
diff changeset
127 > type;
anatofuz
parents:
diff changeset
128 };
anatofuz
parents:
diff changeset
129
anatofuz
parents:
diff changeset
130 DependentTemplateSpecializationTypeTester4<HasApply, int> DTSTCheck4; // expected-note{{in instantiation of template class}}
anatofuz
parents:
diff changeset
131
anatofuz
parents:
diff changeset
132 template<template<class T> class TTP>
anatofuz
parents:
diff changeset
133 struct AcceptedTemplateTemplateParameter {
anatofuz
parents:
diff changeset
134 };
anatofuz
parents:
diff changeset
135
anatofuz
parents:
diff changeset
136 template<typename T, typename U>
anatofuz
parents:
diff changeset
137 struct DependentTemplateTemplateArgumentTester {
anatofuz
parents:
diff changeset
138 typedef AcceptedTemplateTemplateParameter<
anatofuz
parents:
diff changeset
139 T::
anatofuz
parents:
diff changeset
140 template apply<
anatofuz
parents:
diff changeset
141 typename add_reference<U>::type
anatofuz
parents:
diff changeset
142 * // expected-error{{declared as a pointer to a reference of type}}
anatofuz
parents:
diff changeset
143 >::
anatofuz
parents:
diff changeset
144 template X>
anatofuz
parents:
diff changeset
145 type;
anatofuz
parents:
diff changeset
146 };
anatofuz
parents:
diff changeset
147
anatofuz
parents:
diff changeset
148 DependentTemplateTemplateArgumentTester<HasApply, int> DTTACheck; // expected-note{{in instantiation of template class}}
anatofuz
parents:
diff changeset
149
anatofuz
parents:
diff changeset
150 namespace PR9388 {
anatofuz
parents:
diff changeset
151 namespace std {
anatofuz
parents:
diff changeset
152 template<typename T> class vector {
anatofuz
parents:
diff changeset
153 };
anatofuz
parents:
diff changeset
154 }
anatofuz
parents:
diff changeset
155 template<typename T> static void foo(std::vector<T*> &V) {
anatofuz
parents:
diff changeset
156 __PRETTY_FUNCTION__; // expected-warning{{expression result unused}}
anatofuz
parents:
diff changeset
157 }
anatofuz
parents:
diff changeset
158 void bar(std::vector<int*> &Blocks) {
anatofuz
parents:
diff changeset
159 foo(Blocks); // expected-note{{in instantiation of}}
anatofuz
parents:
diff changeset
160 }
anatofuz
parents:
diff changeset
161
anatofuz
parents:
diff changeset
162 }