Clang Project

clang_source_code/test/PCH/cxx2a-bitfield-init.cpp
1// RUN: %clang_cc1 -std=c++2a -include %s -verify %s
2// RUN: %clang_cc1 -std=c++2a -emit-pch %s -o %t
3// RUN: %clang_cc1 -std=c++2a -include-pch %t -verify %s -DPCH
4
5#ifndef HEADER
6#define HEADER
7
8struct S {
9  unsigned int n : 5 = 49; // expected-warning {{changes value}}
10};
11
12int a;
13template<bool B> struct T {
14  int m : B ? 8 : a = 42;
15};
16
17#else
18
19// expected-error@-5 {{constant expression}} expected-note@-5 {{cannot modify}}
20
21static_assert(S().n == 17);
22static_assert(T<true>().m == 0);
23int q = T<false>().m; // expected-note {{instantiation of}}
24
25#endif
26