xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/nested-name-spec.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify -fblocks %s
2f4a2713aSLionel Sambuc namespace A {
3f4a2713aSLionel Sambuc   struct C {
4f4a2713aSLionel Sambuc     static int cx;
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc     static int cx2;
7f4a2713aSLionel Sambuc 
8f4a2713aSLionel Sambuc     static int Ag1();
9f4a2713aSLionel Sambuc     static int Ag2();
10f4a2713aSLionel Sambuc   };
11*0a6a1f1dSLionel Sambuc   int ax; // expected-note {{'ax' declared here}}
12f4a2713aSLionel Sambuc   void Af();
13f4a2713aSLionel Sambuc }
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc A:: ; // expected-error {{expected unqualified-id}}
16*0a6a1f1dSLionel Sambuc ::A::ax::undef ex3; // expected-error {{'ax' is not a class, namespace, or scoped enumeration}}
17f4a2713aSLionel Sambuc A::undef1::undef2 ex4; // expected-error {{no member named 'undef1'}}
18f4a2713aSLionel Sambuc 
Ag1()19f4a2713aSLionel Sambuc int A::C::Ag1() { return 0; }
20f4a2713aSLionel Sambuc 
Ag2()21f4a2713aSLionel Sambuc static int A::C::Ag2() { return 0; } // expected-error{{'static' can}}
22f4a2713aSLionel Sambuc 
23f4a2713aSLionel Sambuc int A::C::cx = 17;
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc 
26f4a2713aSLionel Sambuc static int A::C::cx2 = 17; // expected-error{{'static' can}}
27f4a2713aSLionel Sambuc 
28f4a2713aSLionel Sambuc class C2 {
29f4a2713aSLionel Sambuc   void m(); // expected-note{{member declaration does not match because it is not const qualified}}
30f4a2713aSLionel Sambuc 
31f4a2713aSLionel Sambuc   void f(const int& parm); // expected-note{{type of 1st parameter of member declaration does not match definition ('const int &' vs 'int')}}
32f4a2713aSLionel Sambuc   void f(int) const; // expected-note{{member declaration does not match because it is const qualified}}
33f4a2713aSLionel Sambuc   void f(float);
34f4a2713aSLionel Sambuc 
35f4a2713aSLionel Sambuc   int x;
36f4a2713aSLionel Sambuc };
37f4a2713aSLionel Sambuc 
m() const38f4a2713aSLionel Sambuc void C2::m() const { } // expected-error{{out-of-line definition of 'm' does not match any declaration in 'C2'}}
39f4a2713aSLionel Sambuc 
f(int)40f4a2713aSLionel Sambuc void C2::f(int) { } // expected-error{{out-of-line definition of 'f' does not match any declaration in 'C2'}}
41f4a2713aSLionel Sambuc 
m()42f4a2713aSLionel Sambuc void C2::m() {
43f4a2713aSLionel Sambuc   x = 0;
44f4a2713aSLionel Sambuc }
45f4a2713aSLionel Sambuc 
46f4a2713aSLionel Sambuc namespace B {
Af()47f4a2713aSLionel Sambuc   void ::A::Af() {} // expected-error {{cannot define or redeclare 'Af' here because namespace 'B' does not enclose namespace 'A'}}
48f4a2713aSLionel Sambuc }
49f4a2713aSLionel Sambuc 
f1()50f4a2713aSLionel Sambuc void f1() {
51f4a2713aSLionel Sambuc   void A::Af(); // expected-error {{definition or redeclaration of 'Af' not allowed inside a function}}
52f4a2713aSLionel Sambuc   void (^x)() = ^{ void A::Af(); }; // expected-error {{definition or redeclaration of 'Af' not allowed inside a block}}
53f4a2713aSLionel Sambuc }
54f4a2713aSLionel Sambuc 
f2()55f4a2713aSLionel Sambuc void f2() {
56f4a2713aSLionel Sambuc   A:: ; // expected-error {{expected unqualified-id}}
57f4a2713aSLionel Sambuc   A::C::undef = 0; // expected-error {{no member named 'undef'}}
58f4a2713aSLionel Sambuc   ::A::C::cx = 0;
59f4a2713aSLionel Sambuc   int x = ::A::ax = A::C::cx;
60f4a2713aSLionel Sambuc   x = sizeof(A::C);
61f4a2713aSLionel Sambuc   x = sizeof(::A::C::cx);
62f4a2713aSLionel Sambuc }
63f4a2713aSLionel Sambuc 
64f4a2713aSLionel Sambuc A::C c1;
65f4a2713aSLionel Sambuc struct A::C c2;
66f4a2713aSLionel Sambuc struct S : public A::C {};
67f4a2713aSLionel Sambuc struct A::undef; // expected-error {{no struct named 'undef' in namespace 'A'}}
68f4a2713aSLionel Sambuc 
69f4a2713aSLionel Sambuc namespace A2 {
70f4a2713aSLionel Sambuc   typedef int INT;
71f4a2713aSLionel Sambuc   struct RC;
72f4a2713aSLionel Sambuc   struct CC {
73f4a2713aSLionel Sambuc     struct NC;
74f4a2713aSLionel Sambuc   };
75f4a2713aSLionel Sambuc }
76f4a2713aSLionel Sambuc 
77f4a2713aSLionel Sambuc struct A2::RC {
78f4a2713aSLionel Sambuc   INT x;
79f4a2713aSLionel Sambuc };
80f4a2713aSLionel Sambuc 
81f4a2713aSLionel Sambuc struct A2::CC::NC {
mA2::CC::NC82f4a2713aSLionel Sambuc   void m() {}
83f4a2713aSLionel Sambuc };
84f4a2713aSLionel Sambuc 
f3()85f4a2713aSLionel Sambuc void f3() {
86f4a2713aSLionel Sambuc   N::x = 0; // expected-error {{use of undeclared identifier 'N'}}
87*0a6a1f1dSLionel Sambuc   // FIXME: Consider including the kind of entity that 'N' is ("variable 'N'
88*0a6a1f1dSLionel Sambuc   // declared here", "template 'X' declared here", etc) to help explain what it
89*0a6a1f1dSLionel Sambuc   // is if it's 'not a class, namespace, or scoped enumeration'.
90*0a6a1f1dSLionel Sambuc   int N; // expected-note {{'N' declared here}}
91*0a6a1f1dSLionel Sambuc   N::x = 0; // expected-error {{'N' is not a class, namespace, or scoped enumeration}}
92f4a2713aSLionel Sambuc   { int A;           A::ax = 0; }
93*0a6a1f1dSLionel Sambuc   { typedef int A;   A::ax = 0; } // expected-error{{'A' (aka 'int') is not a class, namespace, or scoped enumeration}}
94f4a2713aSLionel Sambuc   { typedef A::C A;  A::ax = 0; } // expected-error {{no member named 'ax'}}
95f4a2713aSLionel Sambuc   { typedef A::C A;  A::cx = 0; }
96f4a2713aSLionel Sambuc }
97f4a2713aSLionel Sambuc 
98f4a2713aSLionel Sambuc // make sure the following doesn't hit any asserts
99f4a2713aSLionel Sambuc void f4(undef::C); // expected-error {{use of undeclared identifier 'undef'}}
100f4a2713aSLionel Sambuc 
101f4a2713aSLionel Sambuc typedef void C2::f5(int); // expected-error{{typedef declarator cannot be qualified}}
102f4a2713aSLionel Sambuc 
103f4a2713aSLionel Sambuc void f6(int A2::RC::x); // expected-error{{parameter declarator cannot be qualified}}
104f4a2713aSLionel Sambuc 
105f4a2713aSLionel Sambuc int A2::RC::x; // expected-error{{non-static data member defined out-of-line}}
106f4a2713aSLionel Sambuc 
107f4a2713aSLionel Sambuc void A2::CC::NC::m(); // expected-error{{out-of-line declaration of a member must be a definition}}
108f4a2713aSLionel Sambuc 
109f4a2713aSLionel Sambuc 
110f4a2713aSLionel Sambuc namespace E {
111f4a2713aSLionel Sambuc   int X = 5;
112f4a2713aSLionel Sambuc 
113f4a2713aSLionel Sambuc   namespace Nested {
114f4a2713aSLionel Sambuc     enum E {
115f4a2713aSLionel Sambuc       X = 0
116f4a2713aSLionel Sambuc     };
117f4a2713aSLionel Sambuc 
f()118f4a2713aSLionel Sambuc     void f() {
119*0a6a1f1dSLionel Sambuc       return E::X; // expected-error{{'E::Nested::E' is not a class, namespace, or scoped enumeration}}
120f4a2713aSLionel Sambuc     }
121f4a2713aSLionel Sambuc   }
122f4a2713aSLionel Sambuc }
123f4a2713aSLionel Sambuc 
124f4a2713aSLionel Sambuc 
125f4a2713aSLionel Sambuc class Operators {
126f4a2713aSLionel Sambuc   Operators operator+(const Operators&) const; // expected-note{{member declaration does not match because it is const qualified}}
127f4a2713aSLionel Sambuc   operator bool();
128f4a2713aSLionel Sambuc };
129f4a2713aSLionel Sambuc 
operator +(const Operators &)130f4a2713aSLionel Sambuc Operators Operators::operator+(const Operators&) { // expected-error{{out-of-line definition of 'operator+' does not match any declaration in 'Operators'}}
131f4a2713aSLionel Sambuc   Operators ops;
132f4a2713aSLionel Sambuc   return ops;
133f4a2713aSLionel Sambuc }
134f4a2713aSLionel Sambuc 
operator +(const Operators &) const135f4a2713aSLionel Sambuc Operators Operators::operator+(const Operators&) const {
136f4a2713aSLionel Sambuc   Operators ops;
137f4a2713aSLionel Sambuc   return ops;
138f4a2713aSLionel Sambuc }
139f4a2713aSLionel Sambuc 
operator bool()140f4a2713aSLionel Sambuc Operators::operator bool() {
141f4a2713aSLionel Sambuc   return true;
142f4a2713aSLionel Sambuc }
143f4a2713aSLionel Sambuc 
144f4a2713aSLionel Sambuc namespace A {
145f4a2713aSLionel Sambuc   void g(int&); // expected-note{{type of 1st parameter of member declaration does not match definition ('int &' vs 'const int &')}}
146f4a2713aSLionel Sambuc }
147f4a2713aSLionel Sambuc 
f()148*0a6a1f1dSLionel Sambuc void A::f() {} // expected-error-re{{out-of-line definition of 'f' does not match any declaration in namespace 'A'{{$}}}}
149f4a2713aSLionel Sambuc 
g(const int &)150f4a2713aSLionel Sambuc void A::g(const int&) { } // expected-error{{out-of-line definition of 'g' does not match any declaration in namespace 'A'}}
151f4a2713aSLionel Sambuc 
152f4a2713aSLionel Sambuc struct Struct { };
153f4a2713aSLionel Sambuc 
f()154f4a2713aSLionel Sambuc void Struct::f() { } // expected-error{{out-of-line definition of 'f' does not match any declaration in 'Struct'}}
155f4a2713aSLionel Sambuc 
156f4a2713aSLionel Sambuc void global_func(int);
157f4a2713aSLionel Sambuc void global_func2(int);
158f4a2713aSLionel Sambuc 
159f4a2713aSLionel Sambuc namespace N {
global_func(int)160f4a2713aSLionel Sambuc   void ::global_func(int) { } // expected-error{{definition or redeclaration of 'global_func' cannot name the global scope}}
161f4a2713aSLionel Sambuc 
162f4a2713aSLionel Sambuc   void f();
163f4a2713aSLionel Sambuc   // FIXME: if we move this to a separate definition of N, things break!
164f4a2713aSLionel Sambuc }
global_func2(int)165*0a6a1f1dSLionel Sambuc void ::global_func2(int) { } // expected-warning{{extra qualification on member 'global_func2'}}
166f4a2713aSLionel Sambuc 
f()167f4a2713aSLionel Sambuc void N::f() { } // okay
168f4a2713aSLionel Sambuc 
169f4a2713aSLionel Sambuc struct Y;  // expected-note{{forward declaration of 'Y'}}
170f4a2713aSLionel Sambuc Y::foo y; // expected-error{{incomplete type 'Y' named in nested name specifier}}
171f4a2713aSLionel Sambuc 
X()172f4a2713aSLionel Sambuc X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}}
173f4a2713aSLionel Sambuc 
174f4a2713aSLionel Sambuc struct foo_S {
175f4a2713aSLionel Sambuc   static bool value;
176f4a2713aSLionel Sambuc };
177f4a2713aSLionel Sambuc bool (foo_S::value);
178f4a2713aSLionel Sambuc 
179f4a2713aSLionel Sambuc 
180f4a2713aSLionel Sambuc namespace somens {
181f4a2713aSLionel Sambuc   struct a { }; // expected-note{{candidate constructor (the implicit copy constructor)}}
182f4a2713aSLionel Sambuc }
183f4a2713aSLionel Sambuc 
184f4a2713aSLionel Sambuc template <typename T>
185f4a2713aSLionel Sambuc class foo {
186f4a2713aSLionel Sambuc };
187f4a2713aSLionel Sambuc 
188f4a2713aSLionel Sambuc 
189f4a2713aSLionel Sambuc // PR4452 / PR4451
190f4a2713aSLionel Sambuc foo<somens:a> a2;  // expected-error {{unexpected ':' in nested name specifier}}
191f4a2713aSLionel Sambuc 
192f4a2713aSLionel Sambuc somens::a a3 = a2; // expected-error {{no viable conversion}}
193f4a2713aSLionel Sambuc 
194f4a2713aSLionel Sambuc // typedefs and using declarations.
195f4a2713aSLionel Sambuc namespace test1 {
196f4a2713aSLionel Sambuc   namespace ns {
197f4a2713aSLionel Sambuc     class Counter { public: static int count; };
198f4a2713aSLionel Sambuc     typedef Counter counter;
199f4a2713aSLionel Sambuc   }
200f4a2713aSLionel Sambuc   using ns::counter;
201f4a2713aSLionel Sambuc 
202f4a2713aSLionel Sambuc   class Test {
test1()203f4a2713aSLionel Sambuc     void test1() {
204f4a2713aSLionel Sambuc       counter c;
205f4a2713aSLionel Sambuc       c.count++;
206f4a2713aSLionel Sambuc       counter::count++;
207f4a2713aSLionel Sambuc     }
208f4a2713aSLionel Sambuc   };
209f4a2713aSLionel Sambuc }
210f4a2713aSLionel Sambuc 
211f4a2713aSLionel Sambuc // We still need to do lookup in the lexical scope, even if we push a
212f4a2713aSLionel Sambuc // non-lexical scope.
213f4a2713aSLionel Sambuc namespace test2 {
214f4a2713aSLionel Sambuc   namespace ns {
215f4a2713aSLionel Sambuc     extern int *count_ptr;
216f4a2713aSLionel Sambuc   }
217f4a2713aSLionel Sambuc   namespace {
218f4a2713aSLionel Sambuc     int count = 0;
219f4a2713aSLionel Sambuc   }
220f4a2713aSLionel Sambuc 
221f4a2713aSLionel Sambuc   int *ns::count_ptr = &count;
222f4a2713aSLionel Sambuc }
223f4a2713aSLionel Sambuc 
224f4a2713aSLionel Sambuc // PR6259, invalid case
225f4a2713aSLionel Sambuc namespace test3 {
226f4a2713aSLionel Sambuc   class A; // expected-note {{forward declaration}}
foo(const char * path)227f4a2713aSLionel Sambuc   void foo(const char *path) {
228f4a2713aSLionel Sambuc     A::execute(path); // expected-error {{incomplete type 'test3::A' named in nested name specifier}}
229f4a2713aSLionel Sambuc   }
230f4a2713aSLionel Sambuc }
231f4a2713aSLionel Sambuc 
232f4a2713aSLionel Sambuc namespace PR7133 {
233f4a2713aSLionel Sambuc   namespace A {
234f4a2713aSLionel Sambuc     class Foo;
235f4a2713aSLionel Sambuc   }
236f4a2713aSLionel Sambuc 
237f4a2713aSLionel Sambuc   namespace A {
238f4a2713aSLionel Sambuc     namespace B {
239f4a2713aSLionel Sambuc       bool foo(Foo &);
240f4a2713aSLionel Sambuc     }
241f4a2713aSLionel Sambuc   }
242f4a2713aSLionel Sambuc 
foo(Foo &)243f4a2713aSLionel Sambuc   bool A::B::foo(Foo &) {
244f4a2713aSLionel Sambuc     return false;
245f4a2713aSLionel Sambuc   }
246f4a2713aSLionel Sambuc }
247f4a2713aSLionel Sambuc 
248f4a2713aSLionel Sambuc class CLASS {
249f4a2713aSLionel Sambuc   void CLASS::foo2(); // expected-error {{extra qualification on member 'foo2'}}
250f4a2713aSLionel Sambuc };
251f4a2713aSLionel Sambuc 
252f4a2713aSLionel Sambuc namespace PR8159 {
253f4a2713aSLionel Sambuc   class B { };
254f4a2713aSLionel Sambuc 
255f4a2713aSLionel Sambuc   class A {
256f4a2713aSLionel Sambuc     int A::a; // expected-error{{extra qualification on member 'a'}}
257f4a2713aSLionel Sambuc     static int A::b; // expected-error{{extra qualification on member 'b'}}
258f4a2713aSLionel Sambuc     int ::c; // expected-error{{non-friend class member 'c' cannot have a qualified name}}
259f4a2713aSLionel Sambuc   };
260f4a2713aSLionel Sambuc }
261f4a2713aSLionel Sambuc 
262f4a2713aSLionel Sambuc namespace rdar7980179 {
263f4a2713aSLionel Sambuc   class A { void f0(); }; // expected-note {{previous}}
f0()264f4a2713aSLionel Sambuc   int A::f0() {} // expected-error {{return type of out-of-line definition of 'rdar7980179::A::f0' differs}}
265f4a2713aSLionel Sambuc }
266f4a2713aSLionel Sambuc 
267f4a2713aSLionel Sambuc namespace alias = A;
268f4a2713aSLionel Sambuc double *dp = (alias::C*)0; // expected-error{{cannot initialize a variable of type 'double *' with an rvalue of type 'alias::C *'}}
269f4a2713aSLionel Sambuc 
270f4a2713aSLionel Sambuc // http://llvm.org/PR10109
271f4a2713aSLionel Sambuc namespace PR10109 {
272f4a2713aSLionel Sambuc template<typename T>
273f4a2713aSLionel Sambuc struct A {
274f4a2713aSLionel Sambuc protected:
275f4a2713aSLionel Sambuc   struct B;
276f4a2713aSLionel Sambuc   struct B::C; // expected-error {{requires a template parameter list}} \
277f4a2713aSLionel Sambuc                // expected-error {{no struct named 'C'}} \
278f4a2713aSLionel Sambuc     // expected-error{{non-friend class member 'C' cannot have a qualified name}}
279f4a2713aSLionel Sambuc };
280f4a2713aSLionel Sambuc 
281f4a2713aSLionel Sambuc template<typename T>
282f4a2713aSLionel Sambuc struct A2 {
283f4a2713aSLionel Sambuc protected:
284f4a2713aSLionel Sambuc   struct B;
285f4a2713aSLionel Sambuc };
286f4a2713aSLionel Sambuc template <typename T>
287f4a2713aSLionel Sambuc struct A2<T>::B::C; // expected-error {{no struct named 'C'}}
288f4a2713aSLionel Sambuc }
289f4a2713aSLionel Sambuc 
290f4a2713aSLionel Sambuc namespace PR13033 {
291f4a2713aSLionel Sambuc namespace NS {
292f4a2713aSLionel Sambuc  int a; // expected-note {{'NS::a' declared here}}
293f4a2713aSLionel Sambuc  int longer_b; //expected-note {{'NS::longer_b' declared here}}
294f4a2713aSLionel Sambuc }
295f4a2713aSLionel Sambuc 
296f4a2713aSLionel Sambuc // Suggest adding a namespace qualifier to both variable names even though one
297f4a2713aSLionel Sambuc // is only a single character long.
298f4a2713aSLionel Sambuc int foobar = a + longer_b; // expected-error {{use of undeclared identifier 'a'; did you mean 'NS::a'?}} \
299f4a2713aSLionel Sambuc                            // expected-error {{use of undeclared identifier 'longer_b'; did you mean 'NS::longer_b'?}}
300f4a2713aSLionel Sambuc }
301f4a2713aSLionel Sambuc 
302f4a2713aSLionel Sambuc // <rdar://problem/13853540>
303f4a2713aSLionel Sambuc namespace N {
304f4a2713aSLionel Sambuc   struct X { };
305f4a2713aSLionel Sambuc   namespace N {
306f4a2713aSLionel Sambuc     struct Foo {
307f4a2713aSLionel Sambuc       struct N::X *foo(); // expected-error{{no struct named 'X' in namespace 'N::N'}}
308f4a2713aSLionel Sambuc     };
309f4a2713aSLionel Sambuc   }
310f4a2713aSLionel Sambuc }
311f4a2713aSLionel Sambuc 
312f4a2713aSLionel Sambuc namespace TypedefNamespace { typedef int F; };
313*0a6a1f1dSLionel Sambuc TypedefNamespace::F::NonexistentName BadNNSWithCXXScopeSpec; // expected-error {{'F' (aka 'int') is not a class, namespace, or scoped enumeration}}
314*0a6a1f1dSLionel Sambuc 
315*0a6a1f1dSLionel Sambuc namespace PR18587 {
316*0a6a1f1dSLionel Sambuc 
317*0a6a1f1dSLionel Sambuc struct C1 {
318*0a6a1f1dSLionel Sambuc   int a, b, c;
319*0a6a1f1dSLionel Sambuc   typedef int C2;
320*0a6a1f1dSLionel Sambuc   struct B1 {
321*0a6a1f1dSLionel Sambuc     struct B2 {
322*0a6a1f1dSLionel Sambuc       int a, b, c;
323*0a6a1f1dSLionel Sambuc     };
324*0a6a1f1dSLionel Sambuc   };
325*0a6a1f1dSLionel Sambuc };
326*0a6a1f1dSLionel Sambuc struct C2 { static const unsigned N1 = 1; };
327*0a6a1f1dSLionel Sambuc struct B1 {
328*0a6a1f1dSLionel Sambuc   enum E1 { B2 = 2 };
329*0a6a1f1dSLionel Sambuc   static const int B3 = 3;
330*0a6a1f1dSLionel Sambuc };
331*0a6a1f1dSLionel Sambuc const int N1 = 2;
332*0a6a1f1dSLionel Sambuc 
333*0a6a1f1dSLionel Sambuc // Function declarators
334*0a6a1f1dSLionel Sambuc struct S1a { int f(C1::C2); };
335*0a6a1f1dSLionel Sambuc struct S1b { int f(C1:C2); };  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
336*0a6a1f1dSLionel Sambuc 
337*0a6a1f1dSLionel Sambuc struct S2a {
338*0a6a1f1dSLionel Sambuc   C1::C2 f(C1::C2);
339*0a6a1f1dSLionel Sambuc };
340*0a6a1f1dSLionel Sambuc struct S2c {
341*0a6a1f1dSLionel Sambuc   C1::C2 f(C1:C2);  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
342*0a6a1f1dSLionel Sambuc };
343*0a6a1f1dSLionel Sambuc 
344*0a6a1f1dSLionel Sambuc struct S3a {
345*0a6a1f1dSLionel Sambuc   int f(C1::C2), C2 : N1;
346*0a6a1f1dSLionel Sambuc   int g : B1::B2;
347*0a6a1f1dSLionel Sambuc };
348*0a6a1f1dSLionel Sambuc struct S3b {
349*0a6a1f1dSLionel Sambuc   int g : B1:B2;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
350*0a6a1f1dSLionel Sambuc };
351*0a6a1f1dSLionel Sambuc 
352*0a6a1f1dSLionel Sambuc // Inside square brackets
353*0a6a1f1dSLionel Sambuc struct S4a {
354*0a6a1f1dSLionel Sambuc   int f[C2::N1];
355*0a6a1f1dSLionel Sambuc };
356*0a6a1f1dSLionel Sambuc struct S4b {
357*0a6a1f1dSLionel Sambuc   int f[C2:N1];  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
358*0a6a1f1dSLionel Sambuc };
359*0a6a1f1dSLionel Sambuc 
360*0a6a1f1dSLionel Sambuc struct S5a {
361*0a6a1f1dSLionel Sambuc   int f(int xx[B1::B3 ? C2::N1 : B1::B2]);
362*0a6a1f1dSLionel Sambuc };
363*0a6a1f1dSLionel Sambuc struct S5b {
364*0a6a1f1dSLionel Sambuc   int f(int xx[B1::B3 ? C2::N1 : B1:B2]);  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
365*0a6a1f1dSLionel Sambuc };
366*0a6a1f1dSLionel Sambuc struct S5c {
367*0a6a1f1dSLionel Sambuc   int f(int xx[B1:B3 ? C2::N1 : B1::B2]);  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
368*0a6a1f1dSLionel Sambuc };
369*0a6a1f1dSLionel Sambuc 
370*0a6a1f1dSLionel Sambuc // Bit fields
371*0a6a1f1dSLionel Sambuc struct S6a {
372*0a6a1f1dSLionel Sambuc   C1::C2 m1 : B1::B2;
373*0a6a1f1dSLionel Sambuc };
374*0a6a1f1dSLionel Sambuc struct S6c {
375*0a6a1f1dSLionel Sambuc   C1::C2 m1 : B1:B2;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
376*0a6a1f1dSLionel Sambuc };
377*0a6a1f1dSLionel Sambuc struct S6d {
378*0a6a1f1dSLionel Sambuc   int C2:N1;
379*0a6a1f1dSLionel Sambuc };
380*0a6a1f1dSLionel Sambuc struct S6e {
381*0a6a1f1dSLionel Sambuc   static const int N = 3;
382*0a6a1f1dSLionel Sambuc   B1::E1 : N;
383*0a6a1f1dSLionel Sambuc };
384*0a6a1f1dSLionel Sambuc struct S6g {
385*0a6a1f1dSLionel Sambuc   C1::C2 : B1:B2;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
386*0a6a1f1dSLionel Sambuc   B1::E1 : B1:B2;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
387*0a6a1f1dSLionel Sambuc };
388*0a6a1f1dSLionel Sambuc 
389*0a6a1f1dSLionel Sambuc // Template parameters
390*0a6a1f1dSLionel Sambuc template <int N> struct T1 {
391*0a6a1f1dSLionel Sambuc   int a,b,c;
392*0a6a1f1dSLionel Sambuc   static const unsigned N1 = N;
393*0a6a1f1dSLionel Sambuc   typedef unsigned C1;
394*0a6a1f1dSLionel Sambuc };
395*0a6a1f1dSLionel Sambuc T1<C2::N1> var_1a;
396*0a6a1f1dSLionel Sambuc T1<C2:N1> var_1b;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
F()397*0a6a1f1dSLionel Sambuc template<int N> int F() {}
398*0a6a1f1dSLionel Sambuc int (*X1)() = (B1::B2 ? F<1> : F<2>);
399*0a6a1f1dSLionel Sambuc int (*X2)() = (B1:B2 ? F<1> : F<2>);  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
400*0a6a1f1dSLionel Sambuc 
401*0a6a1f1dSLionel Sambuc // Bit fields + templates
402*0a6a1f1dSLionel Sambuc struct S7a {
403*0a6a1f1dSLionel Sambuc   T1<B1::B2>::C1 m1 : T1<B1::B2>::N1;
404*0a6a1f1dSLionel Sambuc };
405*0a6a1f1dSLionel Sambuc struct S7b {
406*0a6a1f1dSLionel Sambuc   T1<B1:B2>::C1 m1 : T1<B1::B2>::N1;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
407*0a6a1f1dSLionel Sambuc };
408*0a6a1f1dSLionel Sambuc struct S7c {
409*0a6a1f1dSLionel Sambuc   T1<B1::B2>::C1 m1 : T1<B1:B2>::N1;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
410*0a6a1f1dSLionel Sambuc };
411*0a6a1f1dSLionel Sambuc 
412*0a6a1f1dSLionel Sambuc }
413