[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / AST / ByteCode / cxx03.cpp
blob70ae4134842b5d7d8d64024469e33570e11e659f
1 // RUN: %clang_cc1 -std=c++03 -verify=expected,both %s -fexperimental-new-constant-interpreter
2 // RUN: %clang_cc1 -std=c++03 -verify=ref,both %s
4 namespace NonInitializingMemberExpr {
5 struct NonLit {
6 NonLit() : value(0) {}
7 int value;
8 };
9 __attribute__((require_constant_initialization)) const int &nl_subobj_ref = NonLit().value; // both-error {{variable does not have a constant initializer}} \
10 // both-note {{required by}} \
11 // both-note {{subexpression not valid}}
15 namespace NonLValueMemberExpr {
16 struct PODType {
17 int value;
20 #define ATTR __attribute__((require_constant_initialization))
21 struct TT1 {
22 ATTR static const int &subobj_init;
25 const int &TT1::subobj_init = PODType().value;
28 void LambdaAccessingADummy() {
29 int d;
30 int a9[1] = {[d = 0] = 1}; // both-error {{is not an integral constant expression}}