2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2008-12-21 07:49:58 +08:00
|
|
|
|
|
|
|
class X{
|
|
|
|
public:
|
2010-04-26 04:55:08 +08:00
|
|
|
enum E {Enumerator}; // expected-note 2{{declared here}}
|
2008-12-21 07:49:58 +08:00
|
|
|
int f();
|
|
|
|
static int mem;
|
|
|
|
static float g();
|
|
|
|
};
|
|
|
|
|
|
|
|
void test(X* xp, X x) {
|
|
|
|
int i1 = x.f();
|
|
|
|
int i2 = xp->f();
|
2010-04-26 04:55:08 +08:00
|
|
|
x.E; // expected-error{{cannot refer to type member 'E' in 'X' with '.'}}
|
|
|
|
xp->E; // expected-error{{cannot refer to type member 'E' in 'X' with '->'}}
|
2009-01-16 11:02:29 +08:00
|
|
|
int i3 = x.Enumerator;
|
|
|
|
int i4 = xp->Enumerator;
|
2008-12-21 07:49:58 +08:00
|
|
|
x.mem = 1;
|
|
|
|
xp->mem = 2;
|
|
|
|
float f1 = x.g();
|
|
|
|
float f2 = xp->g();
|
|
|
|
}
|
2009-03-27 14:00:30 +08:00
|
|
|
|
|
|
|
struct A {
|
|
|
|
int f0;
|
|
|
|
};
|
|
|
|
struct B {
|
|
|
|
A *f0();
|
|
|
|
};
|
|
|
|
int f0(B *b) {
|
2009-11-06 14:30:47 +08:00
|
|
|
return b->f0->f0; // expected-error{{perhaps you meant to call this function}}
|
2009-03-27 14:00:30 +08:00
|
|
|
}
|
2009-10-18 06:37:54 +08:00
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
namespace C {
|
|
|
|
int i;
|
|
|
|
}
|
|
|
|
|
|
|
|
void test2(X *xp) {
|
|
|
|
xp->::i = 7; // expected-error{{qualified member access refers to a member in the global namespace}}
|
|
|
|
xp->C::i = 7; // expected-error{{qualified member access refers to a member in namespace 'C'}}
|
|
|
|
}
|
2009-12-02 06:28:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
namespace test3 {
|
|
|
|
struct NamespaceDecl;
|
|
|
|
|
|
|
|
struct NamedDecl {
|
|
|
|
void *getIdentifier() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct NamespaceDecl : NamedDecl {
|
|
|
|
bool isAnonymousNamespace() const {
|
|
|
|
return !getIdentifier();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2010-04-26 05:15:30 +08:00
|
|
|
|
|
|
|
namespace test4 {
|
|
|
|
class X {
|
|
|
|
protected:
|
|
|
|
template<typename T> void f(T);
|
|
|
|
};
|
|
|
|
|
|
|
|
class Y : public X {
|
|
|
|
public:
|
|
|
|
using X::f;
|
|
|
|
};
|
|
|
|
|
|
|
|
void test_f(Y y) {
|
|
|
|
y.f(17);
|
|
|
|
}
|
|
|
|
}
|
2010-06-16 16:42:20 +08:00
|
|
|
|
|
|
|
namespace test5 {
|
|
|
|
struct A {
|
|
|
|
template <class T> void foo();
|
|
|
|
};
|
|
|
|
|
|
|
|
void test0(int x) {
|
|
|
|
x.A::foo<int>(); // expected-error {{'int' is not a structure or union}}
|
|
|
|
}
|
|
|
|
|
|
|
|
void test1(A *x) {
|
|
|
|
x.A::foo<int>(); // expected-error {{'test5::A *' is a pointer}}
|
|
|
|
}
|
|
|
|
|
|
|
|
void test2(A &x) {
|
|
|
|
x->A::foo<int>(); // expected-error {{'test5::A' is not a pointer}}
|
|
|
|
}
|
|
|
|
}
|
2010-06-30 03:27:42 +08:00
|
|
|
|
|
|
|
namespace PR7508 {
|
|
|
|
struct A {
|
|
|
|
struct CleanupScope {};
|
|
|
|
void PopCleanupBlock();
|
|
|
|
};
|
|
|
|
|
|
|
|
void foo(A &a) {
|
|
|
|
a.PopCleanupScope(); // expected-error{{no member named 'PopCleanupScope' in 'PR7508::A'}}
|
|
|
|
}
|
|
|
|
}
|
2010-07-29 06:27:52 +08:00
|
|
|
|
|
|
|
namespace rdar8231724 {
|
|
|
|
namespace N {
|
|
|
|
template<typename T> struct X1;
|
|
|
|
int i;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct X { };
|
|
|
|
struct Y : X { };
|
|
|
|
|
|
|
|
void f(Y *y) {
|
|
|
|
y->N::X1<int>; // expected-error{{'rdar8231724::N::X1' is not a member of class 'rdar8231724::Y'}}
|
|
|
|
}
|
|
|
|
}
|