xref: /llvm-project/clang/test/AST/ByteCode/mutable.cpp (revision a07aba5d44204a7ca0d891a3da05af9960081e4c)
1 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++11 -verify=expected,expected11,both,both11 %s
2 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++14 -verify=expected,expected14,both %s
3 // RUN: %clang_cc1 -std=c++11 -verify=ref,ref11,both,both11 %s
4 // RUN: %clang_cc1 -std=c++14 -verify=ref,ref14,both %s
5 
6 
7 
8 
9 
10 namespace Simple {
11   struct S {
12     mutable int a; // both-note {{declared here}} \
13                    // both11-note {{declared here}}
14     int a2;
15   };
16 
17   constexpr S s{12, 24};
18   static_assert(s.a == 12, ""); // both-error {{not an integral constant expression}}  \
19                                 // both-note {{read of mutable member 'a'}}
20   static_assert(s.a2 == 24, "");
21 
22 
23   constexpr S s2{12, s2.a}; // both11-error {{must be initialized by a constant expression}} \
24                             // both11-note {{read of mutable member 'a'}} \
25                             // both11-note {{declared here}}
26   static_assert(s2.a2 == 12, ""); // both11-error {{not an integral constant expression}} \
27                                   // both11-note {{initializer of 's2' is not a constant expression}}
28 }
29