[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / qual-id-test.cpp
blob61e60ae82dfa304cad67bfe6efa67432c3f90572
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
5 namespace A
7 namespace B
9 struct base
10 #if __cplusplus <= 199711L
11 // expected-note@-2 {{lookup in the object type 'A::sub' refers here}}
12 #endif
14 void x() {}
15 void y() {}
19 struct member
21 void foo();
24 struct middleman
26 member * operator->() { return 0; }
29 struct sub : B::base
31 void x() {}
32 middleman operator->() { return middleman(); }
36 struct bad
38 int x();
41 namespace C
43 void fun()
45 A::sub a;
47 a.x();
49 a.sub::x();
50 a.base::x();
52 a.B::base::x(); // expected-error{{use of undeclared identifier 'B'}}
54 a.A::sub::x();
55 a.A::B::base::x();
57 a.bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}}
59 a->foo();
60 a->member::foo();
61 a->A::member::foo();
64 void fun2()
66 A::sub *a;
68 a->x();
70 a->sub::x();
71 a->base::x();
73 a->B::base::x(); // expected-error{{use of undeclared identifier 'B'}}
75 a->A::sub::x();
76 a->A::B::base::x();
78 a->bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}}
80 (*a)->foo();
81 (*a)->member::foo();
82 (*a)->A::member::foo();
85 void fun3()
87 int i;
88 i.foo(); // expected-error{{member reference base type 'int' is not a structure or union}}
91 void fun4a() {
92 A::sub *a;
94 typedef A::member base;
95 #if __cplusplus <= 199711L
96 // expected-note@-2 {{lookup from the current scope refers here}}
97 #endif
98 a->base::x();
99 #if __cplusplus <= 199711L
100 // expected-error@-2 {{lookup of 'base' in member access expression is ambiguous}}
101 #endif
104 void fun4b() {
105 A::sub *a;
107 typedef A::B::base base;
108 a->base::x();
111 template<typename T>
112 void fun5()
114 T a;
115 a.x();
116 a->foo();
118 a.A::sub::x();
119 a.A::B::base::x();
120 a->A::member::foo();
122 a.bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}}
125 void test_fun5() {
126 fun5<A::sub>(); // expected-note{{instantiation}}
129 template<typename T>
130 void fun6() {
131 T a;
132 a.sub::x();
133 a.base::x();
134 a->member::foo();
135 a.B::base::x(); // expected-error{{use of undeclared identifier 'B'}}
138 void test_fun6() {
139 fun6<A::sub>(); // expected-note{{instantiation}}
144 // PR4703
145 struct a {
146 int a;
147 static int sa;
150 a a;
152 int a::sa = a.a; // expected-error {{invalid use of non-static data member 'a'}}
155 namespace PR6645 {
156 typedef int foo;
157 namespace Inner {
158 typedef int PR6645::foo; // expected-error{{typedef declarator cannot be qualified}} \
159 // expected-error{{cannot define or redeclare 'foo' here because namespace 'Inner' does not enclose namespace 'PR6645'}}