summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-06-29 13:11:49 -0700
committerGitHub <noreply@github.com>2023-06-29 13:11:49 -0700
commitdccc9091c8f8f0911c79f7f6662c70c627249997 (patch)
treea043e9143c947b3ef36a19a84af3ea5497e118ca /tests
parentb45e5aa07cf5e2e0bd23cf4c14bb40104b0b641c (diff)
Warn on semicolon after `if`. (#2948)
* Warn on semicolon after `if`. * add test result --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/diagnostics/if-empty-body.slang11
-rw-r--r--tests/diagnostics/if-empty-body.slang.expected8
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/diagnostics/if-empty-body.slang b/tests/diagnostics/if-empty-body.slang
new file mode 100644
index 000000000..de8983352
--- /dev/null
+++ b/tests/diagnostics/if-empty-body.slang
@@ -0,0 +1,11 @@
+//DIAGNOSTIC_TEST(windows):SIMPLE:
+
+// Test that use of empty statement after an `if` leads to an warning.
+
+struct S {}
+
+void test()
+{
+ if (1+1==2);
+ return;
+} \ No newline at end of file
diff --git a/tests/diagnostics/if-empty-body.slang.expected b/tests/diagnostics/if-empty-body.slang.expected
new file mode 100644
index 000000000..30915e39d
--- /dev/null
+++ b/tests/diagnostics/if-empty-body.slang.expected
@@ -0,0 +1,8 @@
+result code = 0
+standard error = {
+tests/diagnostics/if-empty-body.slang(9): warning 20101: potentially unintended empty statement at this location; use {} instead.
+ if (1+1==2);
+ ^
+}
+standard output = {
+}