diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-05-07 03:19:20 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-05-07 03:19:20 +0000 |
| commit | 99005e65cd99854ef6844146f8110fc08dba6fe3 (patch) | |
| tree | 9cba3f4c76910141c3c6bf415657df46c2c9919f /clang/test/SemaCXX/constant-expression-cxx1y.cpp | |
| parent | badcd986bb569b6643a53d9d9d77377673981f2c (diff) | |
| download | bcm5719-llvm-99005e65cd99854ef6844146f8110fc08dba6fe3.tar.gz bcm5719-llvm-99005e65cd99854ef6844146f8110fc08dba6fe3.zip | |
C++1y: an assignment operator is implicitly 'constexpr' if it would only call 'constexpr' assignment operators for a literal class type.
llvm-svn: 181284
Diffstat (limited to 'clang/test/SemaCXX/constant-expression-cxx1y.cpp')
| -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(), ""); +} |

