[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / class / class.nest / p1.cpp
blob59bf50f4240059209954c0e1f0bec42b7b96580c
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 class Outer {
6 int x;
7 static int sx;
8 int f();
10 // 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 class Inner {
12 static char a[sizeof(x)];
13 #if __cplusplus <= 199711L
14 // expected-error@-2 {{invalid use of non-static data member 'x'}}
15 #endif
16 static char b[sizeof(sx)]; // okay
17 static char c[sizeof(f)]; // expected-error {{call to non-static member function without an object argument}}