From c1967460749821454d5345b6b3782370d9c5d2c6 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 23 Mar 2024 11:47:12 -0700 Subject: Add tests for standard enum types --- test/enum.c | 23 +++++++++++++++++++++++ test/enum.qbe | 0 2 files changed, 23 insertions(+) create mode 100644 test/enum.c create mode 100644 test/enum.qbe diff --git a/test/enum.c b/test/enum.c new file mode 100644 index 0000000..20ea64d --- /dev/null +++ b/test/enum.c @@ -0,0 +1,23 @@ +enum E1 { + A1 = 1u, + B1 = -1, + A1type = __builtin_types_compatible_p(typeof(A1), int), + B1type = __builtin_types_compatible_p(typeof(B1), int), +}; +_Static_assert(__builtin_types_compatible_p(typeof(A1), int)); +_Static_assert(A1type == 1); +_Static_assert(__builtin_types_compatible_p(typeof(B1), int)); +_Static_assert(B1type == 1); +_Static_assert(__builtin_types_compatible_p(enum E1, int)); + +enum E2 { + A2 = 1, + B2 = 2, + A2type = __builtin_types_compatible_p(typeof(A2), int), + B2type = __builtin_types_compatible_p(typeof(B2), int), +}; +_Static_assert(__builtin_types_compatible_p(typeof(A2), int)); +_Static_assert(A2type == 1); +_Static_assert(__builtin_types_compatible_p(typeof(B2), int)); +_Static_assert(B2type == 1); +_Static_assert(__builtin_types_compatible_p(enum E2, unsigned)); diff --git a/test/enum.qbe b/test/enum.qbe new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3