Skip to content

Commit 4f149a1

Browse files
committed
[FOLD] update tests
1 parent 1495e87 commit 4f149a1

File tree

2 files changed

+117
-7
lines changed

2 files changed

+117
-7
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// RUN: %clang_cc1 -Wno-unused-value -verify %s
2+
3+
namespace N0 {
4+
template<typename T>
5+
struct A {
6+
int x;
7+
void f();
8+
using X = int;
9+
10+
void not_instantiated(A *a, A &b) {
11+
x;
12+
f();
13+
new X;
14+
15+
this->x;
16+
this->f();
17+
this->A::x;
18+
this->A::f();
19+
20+
a->x;
21+
a->f();
22+
a->A::x;
23+
a->A::f();
24+
25+
(*this).x;
26+
(*this).f();
27+
(*this).A::x;
28+
(*this).A::f();
29+
30+
b.x;
31+
b.f();
32+
b.A::x;
33+
b.A::f();
34+
35+
A::x;
36+
A::f();
37+
new A::X;
38+
39+
y; // expected-error{{use of undeclared identifier 'y'}}
40+
g(); // expected-error{{use of undeclared identifier 'g'}}
41+
new Y; // expected-error{{unknown type name 'Y'}}
42+
43+
this->y; // expected-error{{no member named 'y' in 'A<T>'}}
44+
this->g(); // expected-error{{no member named 'g' in 'A<T>'}}
45+
this->A::y; // expected-error{{no member named 'y' in 'A<T>'}}
46+
this->A::g(); // expected-error{{no member named 'g' in 'A<T>'}}
47+
48+
a->y; // expected-error{{no member named 'y' in 'A<T>'}}
49+
a->g(); // expected-error{{no member named 'g' in 'A<T>'}}
50+
a->A::y; // expected-error{{no member named 'y' in 'A<T>'}}
51+
a->A::g(); // expected-error{{no member named 'g' in 'A<T>'}}
52+
53+
// FIXME: An overloaded unary 'operator*' is built for these
54+
// even though the operand is a pointer (to a dependent type).
55+
// Type::isOverloadableType should return false for such cases.
56+
(*this).y;
57+
(*this).g();
58+
(*this).A::y;
59+
(*this).A::g();
60+
61+
b.y; // expected-error{{no member named 'y' in 'A<T>'}}
62+
b.g(); // expected-error{{no member named 'g' in 'A<T>'}}
63+
b.A::y; // expected-error{{no member named 'y' in 'A<T>'}}
64+
b.A::g(); // expected-error{{no member named 'g' in 'A<T>'}}
65+
66+
A::y; // expected-error{{no member named 'y' in 'A<T>'}}
67+
A::g(); // expected-error{{no member named 'g' in 'A<T>'}}
68+
new A::Y; // expected-error{{no type named 'Y' in 'A<T>'}}
69+
}
70+
};
71+
} // namespace N0
72+
73+
namespace N1 {
74+
struct A {
75+
template<int I>
76+
void f();
77+
};
78+
79+
template<typename T>
80+
struct B {
81+
template<int I>
82+
void f();
83+
84+
A x;
85+
A g();
86+
87+
void not_instantiated(B *a, B &b) {
88+
f<0>();
89+
this->f<0>();
90+
a->f<0>();
91+
// FIXME: This should not require 'template'!
92+
(*this).f<0>(); // expected-error{{missing 'template' keyword prior to dependent template name 'f'}}
93+
b.f<0>();
94+
95+
x.f<0>();
96+
this->x.f<0>();
97+
a->x.f<0>();
98+
// FIXME: This should not require 'template'!
99+
(*this).x.f<0>(); // expected-error{{missing 'template' keyword prior to dependent template name 'f'}}
100+
b.x.f<0>();
101+
102+
// FIXME: None of these should require 'template'!
103+
g().f<0>(); // expected-error{{missing 'template' keyword prior to dependent template name 'f'}}
104+
this->g().f<0>(); // expected-error{{missing 'template' keyword prior to dependent template name 'f'}}
105+
a->g().f<0>(); // expected-error{{missing 'template' keyword prior to dependent template name 'f'}}
106+
(*this).g().f<0>(); // expected-error{{missing 'template' keyword prior to dependent template name 'f'}}
107+
b.g().f<0>(); // expected-error{{missing 'template' keyword prior to dependent template name 'f'}}
108+
}
109+
};
110+
} // namespace N1

clang/test/SemaTemplate/instantiate-function-1.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
22
template<typename T, typename U>
33
struct X0 {
4-
void f(T x, U y) {
4+
void f(T x, U y) {
55
(void)(x + y); // expected-error{{invalid operands}}
66
}
77
};
@@ -41,7 +41,7 @@ template <typename T> struct X4 {
4141
T f() const {
4242
return; // expected-error{{non-void function 'f' should return a value}}
4343
}
44-
44+
4545
T g() const {
4646
return 1; // expected-error{{void function 'g' should not return a value}}
4747
}
@@ -64,7 +64,7 @@ template<typename T, typename U, typename V> struct X6 {
6464
// IfStmt
6565
if (t > 0)
6666
return u;
67-
else {
67+
else {
6868
if (t < 0)
6969
return v; // expected-error{{cannot initialize return object of type}}
7070
}
@@ -131,12 +131,12 @@ template<typename T> struct Member0 {
131131
t;
132132
t.f;
133133
t->f;
134-
134+
135135
T* tp;
136136
tp.f; // expected-error{{member reference base type 'T *' is not a structure or union}}
137137
tp->f;
138138

139-
this->f;
139+
this->f; // expected-error{{reference to non-static member function must be called}}
140140
this.f; // expected-error{{member reference base type 'Member0<T> *' is not a structure or union}}
141141
}
142142
};
@@ -239,11 +239,11 @@ namespace PR9880 {
239239
static yes_tag check(char[sizeof(&U::luaIndex)]);
240240
enum { value = sizeof(check<T>(0)) == sizeof(yes_tag) };
241241
};
242-
242+
243243
class SomeClass {
244244
public:
245245
int luaIndex(lua_State* L);
246246
};
247-
247+
248248
int i = HasIndexMetamethod<SomeClass>::value;
249249
}

0 commit comments

Comments
 (0)