1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 namespace A 3 { 4 namespace B 5 { 6 struct base // expected-note{{object type}} 7 { xA::B::base8 void x() {} yA::B::base9 void y() {} 10 }; 11 } 12 13 struct member 14 { 15 void foo(); 16 }; 17 18 struct middleman 19 { operator ->A::middleman20 member * operator->() { return 0; } 21 }; 22 23 struct sub : B::base 24 { xA::sub25 void x() {} operator ->A::sub26 middleman operator->() { return middleman(); } 27 }; 28 } 29 30 struct bad 31 { 32 int x(); 33 }; 34 35 namespace C 36 { fun()37 void fun() 38 { 39 A::sub a; 40 41 a.x(); 42 43 a.sub::x(); 44 a.base::x(); 45 46 a.B::base::x(); // expected-error{{use of undeclared identifier 'B'}} 47 48 a.A::sub::x(); 49 a.A::B::base::x(); 50 51 a.bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}} 52 53 a->foo(); 54 a->member::foo(); 55 a->A::member::foo(); 56 } 57 fun2()58 void fun2() 59 { 60 A::sub *a; 61 62 a->x(); 63 64 a->sub::x(); 65 a->base::x(); 66 67 a->B::base::x(); // expected-error{{use of undeclared identifier 'B'}} 68 69 a->A::sub::x(); 70 a->A::B::base::x(); 71 72 a->bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}} 73 74 (*a)->foo(); 75 (*a)->member::foo(); 76 (*a)->A::member::foo(); 77 } 78 fun3()79 void fun3() 80 { 81 int i; 82 i.foo(); // expected-error{{member reference base type 'int' is not a structure or union}} 83 } 84 fun4a()85 void fun4a() { 86 A::sub *a; 87 88 typedef A::member base; // expected-note{{current scope}} 89 a->base::x(); // expected-error{{ambiguous}} 90 } 91 fun4b()92 void fun4b() { 93 A::sub *a; 94 95 typedef A::B::base base; 96 a->base::x(); 97 } 98 99 template<typename T> fun5()100 void fun5() 101 { 102 T a; 103 a.x(); 104 a->foo(); 105 106 a.A::sub::x(); 107 a.A::B::base::x(); 108 a->A::member::foo(); 109 110 a.bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}} 111 } 112 test_fun5()113 void test_fun5() { 114 fun5<A::sub>(); // expected-note{{instantiation}} 115 } 116 117 template<typename T> fun6()118 void fun6() { 119 T a; 120 a.sub::x(); 121 a.base::x(); 122 a->member::foo(); 123 a.B::base::x(); // expected-error{{use of undeclared identifier 'B'}} 124 } 125 test_fun6()126 void test_fun6() { 127 fun6<A::sub>(); // expected-note{{instantiation}} 128 } 129 130 } 131 132 // PR4703 133 struct a { 134 int a; 135 static int sa; 136 }; 137 138 a a; 139 140 int a::sa = a.a; // expected-error {{invalid use of non-static data member 'a'}} 141 142 143 namespace PR6645 { 144 typedef int foo; 145 namespace Inner { 146 typedef int PR6645::foo; // expected-error{{typedef declarator cannot be qualified}} \ 147 // expected-error{{cannot define or redeclare 'foo' here because namespace 'Inner' does not enclose namespace 'PR6645'}} 148 } 149 } 150