[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / enum-bitfield.cpp
blobe78ca5dfa2fc2f9d343416935430da3b4c104a20
1 // RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s
3 enum E {};
5 struct Z {};
6 typedef int Integer;
8 struct X {
9 enum E : 1; // expected-error{{anonymous bit-field}}
10 enum E : Z; // expected-error{{invalid underlying type}}
11 enum E2 : int;
12 enum E3 : Integer;
15 struct Y {
16 enum E : int(2); // expected-error{{anonymous bit-field}}
17 enum E : Z(); // expected-error{{anonymous bit-field}} expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'Z'}}
20 namespace pr18587 {
21 struct A {
22 enum class B {
26 const int C = 4;
27 struct D {
28 A::B : C;
32 enum WithUnderlying : unsigned { wu_value };
33 struct WithUnderlyingBitfield {
34 WithUnderlying wu : 3;
35 } wu = { wu_value };
36 int want_unsigned(unsigned);
37 int want_unsigned(int) = delete;
38 int check_enum_bitfield_promotes_correctly = want_unsigned(wu.wu);