diff options
author | Michael Forney <mforney@mforney.org> | 2024-03-23 11:47:12 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2024-03-23 11:47:12 -0700 |
commit | c1967460749821454d5345b6b3782370d9c5d2c6 (patch) | |
tree | 1e6f872206968f74b92fd74b10be47e84dd3db04 | |
parent | 077df7145836eb86278db2ad31316841940babe4 (diff) |
Add tests for standard enum types
-rw-r--r-- | test/enum.c | 23 | ||||
-rw-r--r-- | test/enum.qbe | 0 |
2 files changed, 23 insertions, 0 deletions
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 --- /dev/null +++ b/test/enum.qbe |