21#include "gdbsupport/enum-flags.h"
22#include "gdbsupport/valid-expr.h"
23#include "gdbsupport/selftest.h"
26namespace enum_flags_tests {
66#if HAVE_IS_TRIVIALLY_COPYABLE
90#define CHECK_VALID(VALID, EXPR_TYPE, EXPR) \
91 CHECK_VALID_EXPR_6 (EF, RE, EF2, RE2, UEF, URE, VALID, EXPR_TYPE, EXPR)
93typedef std::underlying_type<RE>::type
und;
256#if GCC_VERSION >= 5003 || defined __clang__
263typedef unsigned int uns;
267#
if GCC_VERSION >= 5003 || defined __clang__
282#
if GCC_VERSION >= 4009 || defined __clang__
334# pragma GCC diagnostic
push
335# pragma GCC diagnostic ignored
"-Wenum-compare"
340# pragma GCC diagnostic pop
382 constexpr test_flags
f;
389 test_flags
f (FLAG1);
391 SELF_CHECK (
f == FLAG1);
400 constexpr test_flags zero1 = 0;
401 constexpr test_flags zero2 (0);
402 constexpr test_flags zero3 {0};
403 constexpr test_flags zero4 = {0};
419 constexpr test_flags src = FLAG1;
421 constexpr test_flags f1 = src;
422 constexpr test_flags f2 (src);
423 constexpr test_flags f3 {src};
424 constexpr test_flags f4 = {src};
434 test_flags src = FLAG1;
437 dst = std::move (src);
438 SELF_CHECK (dst == FLAG1);
446 constexpr test_flags
f = FLAG1 | FLAG2;
455 SELF_CHECK (
f == (FLAG1 | FLAG2));
458 SELF_CHECK (
f == (FLAG1 | FLAG2));
466 constexpr int some_bits (FLAG1 | FLAG2);
477 test_flags
f = FLAG1;
479 SELF_CHECK (
f == (FLAG1 | FLAG2));
482 test_flags
f = FLAG1;
484 SELF_CHECK (
f == (FLAG1 | FLAG2));
487 test_flags
f = FLAG1;
489 SELF_CHECK (
f == (FLAG1 | FLAG2));
494 test_flags
f = FLAG1 & FLAG2;
499 SELF_CHECK (
f == FLAG2);
503 SELF_CHECK (
f == FLAG2);
507 SELF_CHECK (
f == FLAG2);
512 constexpr test_flags
f = FLAG1 ^ FLAG2;
517 test_flags
f = FLAG1 ^ FLAG2;
519 SELF_CHECK (
f == (FLAG1 | FLAG2 | FLAG3));
521 SELF_CHECK (
f == (FLAG1 | FLAG2));
523 SELF_CHECK (
f == (FLAG1 | FLAG2 | FLAG3));
529 constexpr test_uflags f1 = ~UFLAG1;
530 constexpr test_uflags f2 = ~f1;
538 constexpr test_flags f1 =
true ? FLAG1 : FLAG2;
540 constexpr test_flags f2 =
false ? FLAG1 : FLAG2;
546 constexpr test_flags src = FLAG1;
547 constexpr test_flags f1 =
true ? src : FLAG2;
549 constexpr test_flags f2 =
false ? src : FLAG2;
555 constexpr test_flags src1 = FLAG1;
556 constexpr test_flags src2 = FLAG2;
557 constexpr test_flags f1 =
true ? src1 : src2;
559 constexpr test_flags f2 =
false ? src1 : src2;
568 test_flags
f = FLAG1 | FLAG2;
594 selftests::register_test (
"enum-flags",
gdb_static_assert(sizeof(splay_tree_key) >=sizeof(CORE_ADDR *))
static void push(int indent, string_file *stream, ULONGEST l)
void _initialize_enum_flags_selftests()
#define CHECK_VALID(VALID, EXPR_TYPE, EXPR)
DEF_ENUM_FLAGS_TYPE(RE, EF)
static RE re ATTRIBUTE_UNUSED
std::underlying_type< RE >::type und