diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-08-06 07:09:20 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-08-06 07:09:20 +0000 |
| commit | 49ca8aab584c12dc1020582377484671bb9722f7 (patch) | |
| tree | da5b348911fdff84a4d260fa558079b9b63ca5c4 /clang/test/SemaCXX/constant-expression-cxx1y.cpp | |
| parent | 7418ff460c6bbdb5e861ee0a0eedb039156e9bd4 (diff) | |
| download | bcm5719-llvm-49ca8aab584c12dc1020582377484671bb9722f7.tar.gz bcm5719-llvm-49ca8aab584c12dc1020582377484671bb9722f7.zip | |
PR16755: When initializing or modifying a bitfield member in a constant
expression, truncate the stored value to the size of the bitfield.
llvm-svn: 187782
Diffstat (limited to 'clang/test/SemaCXX/constant-expression-cxx1y.cpp')
| -rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx1y.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/constant-expression-cxx1y.cpp b/clang/test/SemaCXX/constant-expression-cxx1y.cpp index ee88a3b959c..ebe8e989a83 100644 --- a/clang/test/SemaCXX/constant-expression-cxx1y.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx1y.cpp @@ -870,3 +870,20 @@ namespace Lifetime { } static_assert((lifetime_versus_loops(), true), ""); } + +namespace Bitfields { + struct A { + bool b : 3; + int n : 4; + unsigned u : 5; + }; + constexpr bool test() { + A a {}; + a.b += 2; + --a.n; + --a.u; + a.n = -a.n * 3; + return a.b == false && a.n == 3 && a.u == 31; + } + static_assert(test(), ""); +} |

