summaryrefslogtreecommitdiff
path: root/clang/test/SemaCXX/member-expr.cpp
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
committerCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
commitbe1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch)
tree1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaCXX/member-expr.cpp
parentc4626a62754862d20b41e8a46a3574264ea80e6d (diff)
parentf1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff)
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaCXX/member-expr.cpp')
-rw-r--r--clang/test/SemaCXX/member-expr.cpp159
1 files changed, 159 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/member-expr.cpp b/clang/test/SemaCXX/member-expr.cpp
new file mode 100644
index 0000000..dbddd1c
--- /dev/null
+++ b/clang/test/SemaCXX/member-expr.cpp
@@ -0,0 +1,159 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class X{
+public:
+ enum E {Enumerator}; // expected-note 2{{declared here}}
+ int f();
+ static int mem;
+ static float g();
+};
+
+void test(X* xp, X x) {
+ int i1 = x.f();
+ int i2 = xp->f();
+ 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 '->'}}
+ int i3 = x.Enumerator;
+ int i4 = xp->Enumerator;
+ x.mem = 1;
+ xp->mem = 2;
+ float f1 = x.g();
+ float f2 = xp->g();
+}
+
+struct A {
+ int f0;
+};
+struct B {
+ A *f0();
+};
+int f0(B *b) {
+ return b->f0->f0; // expected-error{{did you mean to call it with no arguments}}
+}
+
+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'}}
+}
+
+
+namespace test3 {
+ struct NamespaceDecl;
+
+ struct NamedDecl {
+ void *getIdentifier() const;
+ };
+
+ struct NamespaceDecl : NamedDecl {
+ bool isAnonymousNamespace() const {
+ return !getIdentifier();
+ }
+ };
+}
+
+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);
+ }
+}
+
+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}}
+ }
+}
+
+namespace PR7508 {
+ struct A {
+ struct CleanupScope {};
+ void PopCleanupBlock(); // expected-note{{'PopCleanupBlock' declared here}}
+ };
+
+ void foo(A &a) {
+ a.PopCleanupScope(); // expected-error{{no member named 'PopCleanupScope' in 'PR7508::A'; did you mean 'PopCleanupBlock'?}}
+ }
+}
+
+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'}}
+ }
+}
+
+namespace PR9025 {
+ struct S { int x; };
+ S fun(); // expected-note{{possible target for call}}
+ int fun(int i); // expected-note{{possible target for call}}
+ int g() {
+ return fun.x; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
+ }
+
+ S fun2(); // expected-note{{possible target for call}}
+ S fun2(int i); // expected-note{{possible target for call}}
+ int g2() {
+ return fun2.x; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
+ }
+
+ S fun3(int i=0); // expected-note{{possible target for call}}
+ int fun3(int i, int j); // expected-note{{possible target for call}}
+ int g3() {
+ return fun3.x; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
+ }
+
+ template <typename T> S fun4(); // expected-note{{possible target for call}}
+ int g4() {
+ return fun4.x; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
+ }
+
+ S fun5(int i); // expected-note{{possible target for call}}
+ S fun5(float f); // expected-note{{possible target for call}}
+ int g5() {
+ return fun5.x; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
+ }
+}
+
+namespace FuncInMemberExpr {
+ struct Vec { int size(); };
+ Vec fun1();
+ int test1() { return fun1.size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}}
+ Vec *fun2();
+ int test2() { return fun2->size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}}
+ Vec fun3(int x = 0);
+ int test3() { return fun3.size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}}
+}