member-expr.cpp revision 2b147f072b118607aafafd2f05843243abfe4488
1// RUN: %clang_cc1 -fsyntax-only -verify %s 2 3class X{ 4public: 5 enum E {Enumerator}; // expected-note 2{{declared here}} 6 int f(); 7 static int mem; 8 static float g(); 9}; 10 11void test(X* xp, X x) { 12 int i1 = x.f(); 13 int i2 = xp->f(); 14 x.E; // expected-error{{cannot refer to type member 'E' in 'X' with '.'}} 15 xp->E; // expected-error{{cannot refer to type member 'E' in 'X' with '->'}} 16 int i3 = x.Enumerator; 17 int i4 = xp->Enumerator; 18 x.mem = 1; 19 xp->mem = 2; 20 float f1 = x.g(); 21 float f2 = xp->g(); 22} 23 24struct A { 25 int f0; 26}; 27struct B { 28 A *f0(); 29}; 30int f0(B *b) { 31 return b->f0->f0; // expected-error{{perhaps you meant to call this function}} 32} 33 34int i; 35 36namespace C { 37 int i; 38} 39 40void test2(X *xp) { 41 xp->::i = 7; // expected-error{{qualified member access refers to a member in the global namespace}} 42 xp->C::i = 7; // expected-error{{qualified member access refers to a member in namespace 'C'}} 43} 44 45 46namespace test3 { 47 struct NamespaceDecl; 48 49 struct NamedDecl { 50 void *getIdentifier() const; 51 }; 52 53 struct NamespaceDecl : NamedDecl { 54 bool isAnonymousNamespace() const { 55 return !getIdentifier(); 56 } 57 }; 58} 59 60namespace test4 { 61 class X { 62 protected: 63 template<typename T> void f(T); 64 }; 65 66 class Y : public X { 67 public: 68 using X::f; 69 }; 70 71 void test_f(Y y) { 72 y.f(17); 73 } 74} 75