xref: /llvm-project/clang/test/CXX/class/class.nest/p3.cpp (revision c6e68daac0fa6e77a89f3ca72f266a528503dd1c)
1f50ef6edSChandler Carruth // RUN: %clang_cc1 -fsyntax-only -verify %s
2*c6e68daaSAndy Gibbs // expected-no-diagnostics
3f50ef6edSChandler Carruth 
4f50ef6edSChandler Carruth // C++0x [class.nest] p3:
5f50ef6edSChandler Carruth //   If class X is defined in a namespace scope, a nested class Y may be
6f50ef6edSChandler Carruth //   declared in class X and later defined in the definition of class X or be
7f50ef6edSChandler Carruth //   later defined in a namespace scope enclosing the definition of class X.
8f50ef6edSChandler Carruth 
9f50ef6edSChandler Carruth namespace example {
10f50ef6edSChandler Carruth   class E {
11f50ef6edSChandler Carruth     class I1;
12f50ef6edSChandler Carruth     class I2;
13f50ef6edSChandler Carruth     class I1 { };
14f50ef6edSChandler Carruth   };
15f50ef6edSChandler Carruth   class E::I2 { };
16f50ef6edSChandler Carruth }
17f50ef6edSChandler Carruth 
18f50ef6edSChandler Carruth // Don't insert out-of-line inner class definitions into the namespace scope.
19f50ef6edSChandler Carruth namespace PR6107 {
20f50ef6edSChandler Carruth   struct S1 { };
21f50ef6edSChandler Carruth   struct S2 {
22f50ef6edSChandler Carruth     struct S1;
23f50ef6edSChandler Carruth   };
24f50ef6edSChandler Carruth   struct S2::S1 { };
25f50ef6edSChandler Carruth   S1 s1;
26f50ef6edSChandler Carruth }
27