aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-07-04 14:07:08 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-07-04 14:07:08 -0700
commitf59bd2be539ce736d2ef04d16f48980d9c02a3ab (patch)
treea45a698a1836f350fd7992c7749932e4e1232f73 /test
parent6db190cf708d6ddb1c51d294c6f5a9416106277f (diff)
parentd65e248ed130da21e554807c8ce6add9773e0670 (diff)
downloadzig-f59bd2be539ce736d2ef04d16f48980d9c02a3ab.tar.gz
zig-f59bd2be539ce736d2ef04d16f48980d9c02a3ab.zip
Merge remote-tracking branch 'origin/master' into llvm14
Diffstat (limited to 'test')
-rw-r--r--test/translate_c.zig55
1 files changed, 53 insertions, 2 deletions
diff --git a/test/translate_c.zig b/test/translate_c.zig
index f5748f0659..b8d39ff797 100644
--- a/test/translate_c.zig
+++ b/test/translate_c.zig
@@ -6,6 +6,53 @@ const CrossTarget = std.zig.CrossTarget;
pub fn addCases(cases: *tests.TranslateCContext) void {
const default_enum_type = if (builtin.abi == .msvc) "c_int" else "c_uint";
+ cases.add("do while with breaks",
+ \\void foo(int a) {
+ \\ do {
+ \\ if (a) break;
+ \\ } while (4);
+ \\ do {
+ \\ if (a) break;
+ \\ } while (0);
+ \\ do {
+ \\ if (a) break;
+ \\ } while (a);
+ \\ do {
+ \\ break;
+ \\ } while (3);
+ \\ do {
+ \\ break;
+ \\ } while (0);
+ \\ do {
+ \\ break;
+ \\ } while (a);
+ \\}
+ , &[_][]const u8{
+ \\pub export fn foo(arg_a: c_int) void {
+ \\ var a = arg_a;
+ \\ while (true) {
+ \\ if (a != 0) break;
+ \\ }
+ \\ while (true) {
+ \\ if (a != 0) break;
+ \\ if (!false) break;
+ \\ }
+ \\ while (true) {
+ \\ if (a != 0) break;
+ \\ if (!(a != 0)) break;
+ \\ }
+ \\ while (true) {
+ \\ break;
+ \\ }
+ \\ while (true) {
+ \\ break;
+ \\ }
+ \\ while (true) {
+ \\ break;
+ \\ }
+ \\}
+ });
+
cases.add("variables check for opaque demotion",
\\struct A {
\\ _Atomic int a;
@@ -441,7 +488,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\pub export fn foo() void {
\\ while (false) while (false) {};
\\ while (true) while (false) {};
- \\ while (true) {}
+ \\ while (true) while (true) {
+ \\ if (!false) break;
+ \\ };
\\}
});
@@ -3229,7 +3278,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\}
, &[_][]const u8{
\\pub fn foo() callconv(.C) void {
- \\ if (true) {}
+ \\ if (true) while (true) {
+ \\ if (!false) break;
+ \\ };
\\}
});