|
|
|
@ -67,7 +67,7 @@ DEF_ENUM_FLAGS_TYPE (URE, UEF); |
|
|
|
|
|
|
|
/* So that std::vectors of types that have enum_flags fields can
|
|
|
|
reallocate efficiently memcpy. */ |
|
|
|
gdb_static_assert (std::is_trivially_copyable<EF>::value); |
|
|
|
static_assert (std::is_trivially_copyable<EF>::value); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
@ -407,7 +407,7 @@ self_test () |
|
|
|
{ |
|
|
|
constexpr test_flags f; |
|
|
|
|
|
|
|
gdb_static_assert (f == 0); |
|
|
|
static_assert (f == 0); |
|
|
|
} |
|
|
|
|
|
|
|
/* Check that assignment from zero works. */ |
|
|
|
@ -428,16 +428,16 @@ self_test () |
|
|
|
constexpr test_flags zero3 {0}; |
|
|
|
constexpr test_flags zero4 = {0}; |
|
|
|
|
|
|
|
gdb_static_assert (zero1 == 0); |
|
|
|
gdb_static_assert (zero2 == 0); |
|
|
|
gdb_static_assert (zero3 == 0); |
|
|
|
gdb_static_assert (zero4 == 0); |
|
|
|
static_assert (zero1 == 0); |
|
|
|
static_assert (zero2 == 0); |
|
|
|
static_assert (zero3 == 0); |
|
|
|
static_assert (zero4 == 0); |
|
|
|
} |
|
|
|
|
|
|
|
/* Check construction from enum value. */ |
|
|
|
{ |
|
|
|
gdb_static_assert (test_flags (FLAG1) == FLAG1); |
|
|
|
gdb_static_assert (test_flags (FLAG2) != FLAG1); |
|
|
|
static_assert (test_flags (FLAG1) == FLAG1); |
|
|
|
static_assert (test_flags (FLAG2) != FLAG1); |
|
|
|
} |
|
|
|
|
|
|
|
/* Check copy/assignment. */ |
|
|
|
@ -449,10 +449,10 @@ self_test () |
|
|
|
constexpr test_flags f3 {src}; |
|
|
|
constexpr test_flags f4 = {src}; |
|
|
|
|
|
|
|
gdb_static_assert (f1 == FLAG1); |
|
|
|
gdb_static_assert (f2 == FLAG1); |
|
|
|
gdb_static_assert (f3 == FLAG1); |
|
|
|
gdb_static_assert (f4 == FLAG1); |
|
|
|
static_assert (f1 == FLAG1); |
|
|
|
static_assert (f2 == FLAG1); |
|
|
|
static_assert (f3 == FLAG1); |
|
|
|
static_assert (f4 == FLAG1); |
|
|
|
} |
|
|
|
|
|
|
|
/* Check moving. */ |
|
|
|
@ -470,7 +470,7 @@ self_test () |
|
|
|
to test_flags would fail. */ |
|
|
|
{ |
|
|
|
constexpr test_flags f = FLAG1 | FLAG2; |
|
|
|
gdb_static_assert (f == (FLAG1 | FLAG2)); |
|
|
|
static_assert (f == (FLAG1 | FLAG2)); |
|
|
|
} |
|
|
|
|
|
|
|
/* Similarly, check that "FLAG1 | FLAG2" on the rhs of an assignment
|
|
|
|
@ -492,8 +492,8 @@ self_test () |
|
|
|
constexpr int some_bits (FLAG1 | FLAG2); |
|
|
|
|
|
|
|
/* And comparison with int works too. */ |
|
|
|
gdb_static_assert (some_bits == (FLAG1 | FLAG2)); |
|
|
|
gdb_static_assert (some_bits == test_flags (FLAG1 | FLAG2)); |
|
|
|
static_assert (some_bits == (FLAG1 | FLAG2)); |
|
|
|
static_assert (some_bits == test_flags (FLAG1 | FLAG2)); |
|
|
|
} |
|
|
|
|
|
|
|
/* Check operator| and operator|=. Particularly interesting is
|
|
|
|
@ -536,7 +536,7 @@ self_test () |
|
|
|
/* Check the ^/^= operators. */ |
|
|
|
{ |
|
|
|
constexpr test_flags f = FLAG1 ^ FLAG2; |
|
|
|
gdb_static_assert (f == (FLAG1 ^ FLAG2)); |
|
|
|
static_assert (f == (FLAG1 ^ FLAG2)); |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
@ -554,7 +554,7 @@ self_test () |
|
|
|
{ |
|
|
|
constexpr test_uflags f1 = ~UFLAG1; |
|
|
|
constexpr test_uflags f2 = ~f1; |
|
|
|
gdb_static_assert (f2 == UFLAG1); |
|
|
|
static_assert (f2 == UFLAG1); |
|
|
|
} |
|
|
|
|
|
|
|
/* Check the ternary operator. */ |
|
|
|
@ -562,18 +562,18 @@ self_test () |
|
|
|
{ |
|
|
|
/* raw enum, raw enum */ |
|
|
|
constexpr test_flags f1 = true ? FLAG1 : FLAG2; |
|
|
|
gdb_static_assert (f1 == FLAG1); |
|
|
|
static_assert (f1 == FLAG1); |
|
|
|
constexpr test_flags f2 = false ? FLAG1 : FLAG2; |
|
|
|
gdb_static_assert (f2 == FLAG2); |
|
|
|
static_assert (f2 == FLAG2); |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
/* enum flags, raw enum */ |
|
|
|
constexpr test_flags src = FLAG1; |
|
|
|
constexpr test_flags f1 = true ? src : FLAG2; |
|
|
|
gdb_static_assert (f1 == FLAG1); |
|
|
|
static_assert (f1 == FLAG1); |
|
|
|
constexpr test_flags f2 = false ? src : FLAG2; |
|
|
|
gdb_static_assert (f2 == FLAG2); |
|
|
|
static_assert (f2 == FLAG2); |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
@ -581,9 +581,9 @@ self_test () |
|
|
|
constexpr test_flags src1 = FLAG1; |
|
|
|
constexpr test_flags src2 = FLAG2; |
|
|
|
constexpr test_flags f1 = true ? src1 : src2; |
|
|
|
gdb_static_assert (f1 == src1); |
|
|
|
static_assert (f1 == src1); |
|
|
|
constexpr test_flags f2 = false ? src1 : src2; |
|
|
|
gdb_static_assert (f2 == src2); |
|
|
|
static_assert (f2 == src2); |
|
|
|
} |
|
|
|
|
|
|
|
/* Check that we can use flags in switch expressions (requires
|
|
|
|
|