xref: /llvm-project/clang/test/AST/ByteCode/cxx03.cpp (revision a07aba5d44204a7ca0d891a3da05af9960081e4c)
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
3 
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}}
12 }
13 
14 
15 namespace NonLValueMemberExpr {
16   struct PODType {
17     int value;
18   };
19 
20 #define ATTR __attribute__((require_constant_initialization))
21   struct TT1 {
22     ATTR static const int &subobj_init;
23   };
24 
25   const int &TT1::subobj_init = PODType().value;
26 }
27 
28 void LambdaAccessingADummy() {
29   int d;
30   int a9[1] = {[d = 0] = 1}; // both-error {{is not an integral constant expression}}
31 }
32