xref: /aosp_15_r20/external/clang/test/CXX/class/class.nest/p1.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
4*67e74705SXin Li 
5*67e74705SXin Li class Outer {
6*67e74705SXin Li   int x;
7*67e74705SXin Li   static int sx;
8*67e74705SXin Li   int f();
9*67e74705SXin Li 
10*67e74705SXin Li   // C++11 does relax this rule (see 5.1.1.10) in the first case, but we need to enforce it in C++03 mode.
11*67e74705SXin Li   class Inner {
12*67e74705SXin Li     static char a[sizeof(x)];
13*67e74705SXin Li #if __cplusplus <= 199711L
14*67e74705SXin Li     // expected-error@-2 {{invalid use of non-static data member 'x'}}
15*67e74705SXin Li #endif
16*67e74705SXin Li     static char b[sizeof(sx)]; // okay
17*67e74705SXin Li     static char c[sizeof(f)]; // expected-error {{call to non-static member function without an object argument}}
18*67e74705SXin Li   };
19*67e74705SXin Li };
20