summaryrefslogtreecommitdiff
path: root/test/Parser
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-08-28 00:28:14 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-08-28 00:28:14 +0000
commit81950801a4d5d159de3f1fae870637eec22de68e (patch)
tree31f06b972fc3e8b4d8e0de0d818a3623e02eb1b3 /test/Parser
parentabed2aa96afa09c2bdec84c4c03c4d8f97fe7c0a (diff)
[c++2a] P0683R1: Permit default member initializers for bit-fields.
This would be trivial, except that our in-memory and serialized representations for FieldDecls assumed that this can't happen. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311867 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Parser')
-rw-r--r--test/Parser/cxx2a-bitfield-init.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/Parser/cxx2a-bitfield-init.cpp b/test/Parser/cxx2a-bitfield-init.cpp
new file mode 100644
index 0000000000..83f1575c96
--- /dev/null
+++ b/test/Parser/cxx2a-bitfield-init.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+
+namespace std_example {
+ int a;
+ const int b = 0; // expected-note {{here}}
+ struct S {
+ int x1 : 8 = 42;
+ int x2 : 8 { 42 };
+ int y1 : true ? 8 : a = 42;
+ int y3 : (true ? 8 : b) = 42;
+ int z : 1 || new int { 1 };
+ };
+ static_assert(S{}.x1 == 42);
+ static_assert(S{}.x2 == 42);
+ static_assert(S{}.y1 == 0);
+ static_assert(S{}.y3 == 42);
+ static_assert(S{}.z == 0);
+
+ struct T {
+ int y2 : true ? 8 : b = 42; // expected-error {{cannot assign to variable 'b'}}
+ };
+}