Clang Project

clang_source_code/test/Parser/cxx2a-bitfield-init.cpp
1// RUN: %clang_cc1 -std=c++2a -verify %s
2
3namespace std_example {
4  int a;
5  const int b = 0; // expected-note {{here}}
6  struct S {
7    int x1 : 8 = 42;
8    int x2 : 8 { 42 };
9    int y1 : true ? 8 : a = 42;
10    int y3 : (true ? 8 : b) = 42;
11    int z : 1 || new int { 1 };
12  };
13  static_assert(S{}.x1 == 42);
14  static_assert(S{}.x2 == 42);
15  static_assert(S{}.y1 == 0);
16  static_assert(S{}.y3 == 42);
17  static_assert(S{}.z == 0);
18
19  struct T {
20    int y2 : true ? 8 : b = 42; // expected-error {{cannot assign to variable 'b'}}
21  };
22}
23