1 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
2 // RUN: %clang_cc1 -verify=ref %s
6 constexpr const int &b
= a
;
7 static_assert(a
== b
, "");
9 constexpr int assignToReference() {
16 static_assert(assignToReference() == 100, "");
19 constexpr void setValue(int &dest
, int val
) {
23 constexpr int checkSetValue() {
28 static_assert(checkSetValue() == 200, "");
30 constexpr int readLocalRef() {
35 static_assert(readLocalRef() == 20, "");
37 constexpr int incRef() {
45 static_assert(incRef() == 1, "");
48 template<const int &V
>
49 constexpr void Plus3(int &A
) {
52 constexpr int foo
= 4;
54 constexpr int callTemplate() {
59 static_assert(callTemplate() == 7, "");
62 constexpr int& getValue(int *array
, int index
) {
65 constexpr int testGetValue() {
66 int values
[] = {1, 2, 3, 4};
67 getValue(values
, 2) = 30;
70 static_assert(testGetValue() == 30, "");
72 constexpr const int &MCE
= 20;
73 static_assert(MCE
== 20, "");
74 static_assert(MCE
== 30, ""); // expected-error {{static assertion failed}} \
75 // expected-note {{evaluates to '20 == 30'}} \
76 // ref-error {{static assertion failed}} \
77 // ref-note {{evaluates to '20 == 30'}}
79 constexpr int LocalMCE() {
83 static_assert(LocalMCE() == 100, "");
84 static_assert(LocalMCE() == 200, ""); // expected-error {{static assertion failed}} \
85 // expected-note {{evaluates to '100 == 200'}} \
86 // ref-error {{static assertion failed}} \
87 // ref-note {{evaluates to '100 == 200'}}
93 constexpr int RefToMemberExpr() {
101 static_assert(RefToMemberExpr() == 11, "");
107 constexpr int RecordWithRef() {
113 static_assert(RecordWithRef() == 200, "");
118 constexpr Ref2(int &a
) : a(a
) {}
121 constexpr int RecordWithRef2() {
127 static_assert(RecordWithRef2() == 200, "");