diff options
Diffstat (limited to 'clang/test/SemaCXX')
| -rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx1y.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/constant-expression-cxx1y.cpp b/clang/test/SemaCXX/constant-expression-cxx1y.cpp index 60ec82062de..198b9945da6 100644 --- a/clang/test/SemaCXX/constant-expression-cxx1y.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx1y.cpp @@ -457,3 +457,46 @@ namespace loops { } static_assert(range_for_2() == 10, ""); } + +namespace assignment { + struct A { + constexpr A() : n(5) {} + int n; + struct B { + int k = 1; + union U { + constexpr U() : y(4) {} + int x; + int y; + } u; + } b; + }; + constexpr bool testA() { + A a, b; + a.n = 7; + a.b.u.y = 5; + b = a; + return b.n == 7 && b.b.u.y == 5 && b.b.k == 1; + } + static_assert(testA(), ""); + + struct B { + bool assigned = false; + constexpr B &operator=(const B&) { + assigned = true; + return *this; + } + }; + struct C : B { + B b; + int n = 5; + }; + constexpr bool testC() { + C c, d; + c.n = 7; + d = c; + c.n = 3; + return d.n == 7 && d.assigned && d.b.assigned; + } + static_assert(testC(), ""); +} |

