1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
7 enum E
{Enumerator
}; // expected-note 2{{declared here}}
13 void test(X
* xp
, X x
) {
16 x
.E
; // expected-error{{cannot refer to type member 'E' in 'X' with '.'}}
17 xp
->E
; // expected-error{{cannot refer to type member 'E' in 'X' with '->'}}
18 int i3
= x
.Enumerator
;
19 int i4
= xp
->Enumerator
;
33 return b
->f0
->f0
; // expected-error{{did you mean to call it with no arguments}}
43 xp
->::i
= 7; // expected-error{{qualified member access refers to a member in the global namespace}}
44 xp
->C::i
= 7; // expected-error{{qualified member access refers to a member in namespace 'C'}}
52 void *getIdentifier() const;
55 struct NamespaceDecl
: NamedDecl
{
56 bool isAnonymousNamespace() const {
57 return !getIdentifier();
65 template<typename T
> void f(T
);
80 template <class T
> void foo();
84 x
.A::foo
<int>(); // expected-error {{'int' is not a structure or union}}
88 x
.A::foo
<int>(); // expected-error {{'A *' is a pointer}}
92 x
->A::foo
<int>(); // expected-error {{'A' is not a pointer; did you mean to use '.'?}}
98 struct CleanupScope
{};
99 void PopCleanupBlock(); // expected-note{{'PopCleanupBlock' declared here}}
103 a
.PopCleanupScope(); // expected-error{{no member named 'PopCleanupScope' in 'PR7508::A'; did you mean 'PopCleanupBlock'?}}
107 namespace rdar8231724
{
109 template<typename T
> struct X1
;
116 template<typename T
> struct Z
{ int n
; };
119 y
->N::X1
<int>; // expected-error{{'rdar8231724::N::X1' is not a member of class 'Y'}}
120 y
->Z
<int>::n
; // expected-error{{'rdar8231724::Z<int>::n' is not a member of class 'Y'}}
121 y
->template Z
<int>::n
; // expected-error{{'rdar8231724::Z<int>::n' is not a member of class 'Y'}}
122 #if __cplusplus <= 199711L // C++03 or earlier modes
123 // expected-warning@-2{{'template' keyword outside of a template}}
130 S
fun(); // expected-note{{possible target for call}}
131 int fun(int i
); // expected-note{{possible target for call}}
133 return fun
.x
; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
136 S
fun2(); // expected-note{{possible target for call}}
137 S
fun2(int i
); // expected-note{{possible target for call}}
139 return fun2
.x
; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
142 S
fun3(int i
=0); // expected-note{{possible target for call}}
143 int fun3(int i
, int j
); // expected-note{{possible target for call}}
145 return fun3
.x
; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
148 template <typename T
> S
fun4(); // expected-note{{possible target for call}}
150 return fun4
.x
; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
153 S
fun5(int i
); // expected-note{{possible target for call}}
154 S
fun5(float f
); // expected-note{{possible target for call}}
156 return fun5
.x
; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
160 namespace FuncInMemberExpr
{
161 struct Vec
{ int size(); };
163 int test1() { return fun1
.size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}}
165 int test2() { return fun2
->size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}}
167 int test3() { return fun3
.size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}}
170 namespace DotForSemiTypo
{
172 // If the programmer typo'd '.' for ';', make sure we point at the '.' rather
173 // than the "field name" (whatever the first token on the next line happens to
175 int j
= i
. // expected-error {{member reference base type 'int' is not a structure or union}}
188 return c
->a
; // expected-error {{member reference type 'Cl0' is not a pointer; did you mean to use '.'?}}
192 void func(); // expected-note {{'func' declared here}}
196 bar
operator->(); // expected-note 2 {{'->' applied to return value of the operator->() declared here}}
199 template <class T
> void call_func(T t
) {
200 t
->func(); // expected-error-re 2 {{member reference type '{{(PR15045::)?}}bar' is not a pointer{{$}}}} \
201 // expected-note {{did you mean to use '.' instead?}}
204 void test_arrow_on_non_pointer_records() {
208 // Show that recovery has happened by also triggering typo correction
209 e
->Func(); // expected-error {{member reference type 'bar' is not a pointer; did you mean to use '.'?}} \
210 // expected-error {{no member named 'Func' in 'PR15045::bar'; did you mean 'func'?}}
212 // Make sure a fixit isn't given in the case that the '->' isn't actually
213 // the problem (the problem is with the return value of an operator->).
214 f
->func(); // expected-error-re {{member reference type 'bar' is not a pointer{{$}}}}
216 call_func(e
); // expected-note {{in instantiation of function template specialization 'PR15045::call_func<PR15045::bar>' requested here}}
218 call_func(f
); // expected-note {{in instantiation of function template specialization 'PR15045::call_func<PR15045::foo>' requested here}}
224 struct T
{ S
* get_s(); };
227 return t
.get_s
// expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
228 .i
; // expected-error {{member reference type 'S *' is a pointer; did you mean to use '->'}}