xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/dcl.decl/dcl.meaning/p1.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc namespace PR8019 {
4f4a2713aSLionel Sambuc   struct x;
5f4a2713aSLionel Sambuc   template<typename T> struct x2;
6f4a2713aSLionel Sambuc   struct y {
7f4a2713aSLionel Sambuc     struct PR8019::x { int x; };  // expected-error{{non-friend class member 'x' cannot have a qualified name}}
8f4a2713aSLionel Sambuc 
9f4a2713aSLionel Sambuc     struct inner;
10f4a2713aSLionel Sambuc     struct y::inner { }; // expected-error{{extra qualification on member 'inner'}}
11f4a2713aSLionel Sambuc 
12f4a2713aSLionel Sambuc     template<typename T>
13f4a2713aSLionel Sambuc     struct PR8019::x2 { }; // expected-error{{non-friend class member 'x2' cannot have a qualified name}}
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc     template<typename T>
16f4a2713aSLionel Sambuc     struct inner_template;
17f4a2713aSLionel Sambuc 
18f4a2713aSLionel Sambuc     template<typename T>
19f4a2713aSLionel Sambuc     struct y::inner_template { }; // expected-error{{extra qualification on member 'inner_template'}}
20f4a2713aSLionel Sambuc   };
21f4a2713aSLionel Sambuc 
22f4a2713aSLionel Sambuc }
23f4a2713aSLionel Sambuc 
24f4a2713aSLionel Sambuc namespace NS {
25f4a2713aSLionel Sambuc   void foo();
26f4a2713aSLionel Sambuc   extern int bar;
27f4a2713aSLionel Sambuc   struct X;
28f4a2713aSLionel Sambuc   template<typename T> struct Y;
29f4a2713aSLionel Sambuc   template<typename T> void wibble(T);
30*0a6a1f1dSLionel Sambuc   struct Z;
31f4a2713aSLionel Sambuc }
32f4a2713aSLionel Sambuc namespace NS {
33*0a6a1f1dSLionel Sambuc   // Under DR482, these are all valid, except for forward-declaring a struct
34*0a6a1f1dSLionel Sambuc   // with a nested-name-specifier.
35*0a6a1f1dSLionel Sambuc   void NS::foo(); // expected-warning {{extra qualification}}
36*0a6a1f1dSLionel Sambuc   extern int NS::bar; // expected-warning {{extra qualification}}
37*0a6a1f1dSLionel Sambuc   struct NS::X; // expected-error {{forward declaration of struct cannot have a nested name specifier}} expected-warning {{extra qualification}}
38*0a6a1f1dSLionel Sambuc   template<typename T> struct NS::Y; // expected-error {{forward declaration of struct cannot have a nested name specifier}} expected-warning {{extra qualification}}
39*0a6a1f1dSLionel Sambuc   template<typename T> void NS::wibble(T); // expected-warning {{extra qualification}}
40*0a6a1f1dSLionel Sambuc 
foo()41*0a6a1f1dSLionel Sambuc   void NS::foo() {} // expected-warning{{extra qualification on member 'foo'}}
42*0a6a1f1dSLionel Sambuc   int NS::bar; // expected-warning{{extra qualification on member 'bar'}}
43*0a6a1f1dSLionel Sambuc   struct NS::X { }; // expected-warning{{extra qualification on member 'X'}}
44*0a6a1f1dSLionel Sambuc   template<typename T> struct NS::Y { }; // expected-warning{{extra qualification on member 'Y'}}
wibble(T)45*0a6a1f1dSLionel Sambuc   template<typename T> void NS::wibble(T) { } // expected-warning{{extra qualification on member 'wibble'}}
46f4a2713aSLionel Sambuc }
47*0a6a1f1dSLionel Sambuc 
48*0a6a1f1dSLionel Sambuc struct ::{} a; // expected-error{{expected identifier}}
49*0a6a1f1dSLionel Sambuc struct NS::Z:: {} b; // expected-error{{expected identifier}}
50