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