aboutsummaryrefslogtreecommitdiff
path: root/test/behavior
diff options
context:
space:
mode:
authorEvan Haas <evan@lagerdata.com>2021-08-02 22:44:20 -0700
committerVeikka Tuominen <git@vexu.eu>2021-08-06 09:10:50 +0300
commit9fd3aeb8088cd9a3b0744d5f508ca256a2bbf19f (patch)
tree69422585eaf58ac2f4f1e7fcf30a4aab4b16f3eb /test/behavior
parentfdd97244fda948e0033034aba8042c8fdfb5d484 (diff)
downloadzig-9fd3aeb8088cd9a3b0744d5f508ca256a2bbf19f.tar.gz
zig-9fd3aeb8088cd9a3b0744d5f508ca256a2bbf19f.zip
translate-c: handle macros that cast to cv void
Fixes #9507
Diffstat (limited to 'test/behavior')
-rw-r--r--test/behavior/translate_c_macros.h12
-rw-r--r--test/behavior/translate_c_macros.zig13
2 files changed, 25 insertions, 0 deletions
diff --git a/test/behavior/translate_c_macros.h b/test/behavior/translate_c_macros.h
index 6f458684c7..bff4cdfe23 100644
--- a/test/behavior/translate_c_macros.h
+++ b/test/behavior/translate_c_macros.h
@@ -18,3 +18,15 @@ struct Foo {
#define SIZE_OF_FOO sizeof(struct Foo)
#define MAP_FAILED ((void *) -1)
+
+#define IGNORE_ME_1(x) ((void)(x))
+#define IGNORE_ME_2(x) ((const void)(x))
+#define IGNORE_ME_3(x) ((volatile void)(x))
+#define IGNORE_ME_4(x) ((const volatile void)(x))
+#define IGNORE_ME_5(x) ((volatile const void)(x))
+
+#define IGNORE_ME_6(x) (void)(x)
+#define IGNORE_ME_7(x) (const void)(x)
+#define IGNORE_ME_8(x) (volatile void)(x)
+#define IGNORE_ME_9(x) (const volatile void)(x)
+#define IGNORE_ME_10(x) (volatile const void)(x)
diff --git a/test/behavior/translate_c_macros.zig b/test/behavior/translate_c_macros.zig
index 8de06ae8ea..0daf4cec90 100644
--- a/test/behavior/translate_c_macros.zig
+++ b/test/behavior/translate_c_macros.zig
@@ -24,3 +24,16 @@ test "reference to a struct type" {
test "cast negative integer to pointer" {
try expectEqual(@intToPtr(?*c_void, @bitCast(usize, @as(isize, -1))), h.MAP_FAILED);
}
+
+test "casting to void with a macro" {
+ h.IGNORE_ME_1(42);
+ h.IGNORE_ME_2(42);
+ h.IGNORE_ME_3(42);
+ h.IGNORE_ME_4(42);
+ h.IGNORE_ME_5(42);
+ h.IGNORE_ME_6(42);
+ h.IGNORE_ME_7(42);
+ h.IGNORE_ME_8(42);
+ h.IGNORE_ME_9(42);
+ h.IGNORE_ME_10(42);
+}