Debian Codegraph @

clang/test/AST/ByteCode/cxx03.cpp

raw
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
33 const int p = 10;
34 struct B {
35 int a;
36 void *p;
37 };
38 struct B2 : B {
39 void *q;
40 };
41 _Static_assert(&(B2().a) == &p, ""); // both-error {{taking the address of a temporary object of type 'int'}} \
42 // both-error {{not an integral constant expression}}
43
44 typedef __attribute__((ext_vector_type(4))) int vi4b;
45 struct S {
46 vi4b w;
47 };
48 const int s = S().w[1];
49
50 #if __LP64__
51 namespace NullRecord {
52 struct S {
53 int arr[1024 * 1024 * 1024];
54 s = {1, {2}}; // both-error {{a type specifier is required for all declarations}} \
55 // both-warning {{default member initializer for non-static data member is a C++11 extension}}
56 };
57
58 S s[2] = {};
59 }
60 #endif