summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-04-17 22:22:13 +0800
committerGitHub <noreply@github.com>2023-04-17 22:22:13 +0800
commita3f622ace1bdef1f1a4150ec85d1328d1a589333 (patch)
treec1c620d0e69d39870fdbc76f5e584bae8594f0ba /tests
parentf6ff73fe3156215e75708d155fd240788134b1f2 (diff)
WIP: "deprecated" attribute (#2698)
* Implement deprecated attribute * Prevent duplicate deprecated diagnostic on non-overloaded functions * Use FileCheck for deprecation test * formatting
Diffstat (limited to 'tests')
-rw-r--r--tests/diagnostics/deprecation.slang60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/diagnostics/deprecation.slang b/tests/diagnostics/deprecation.slang
new file mode 100644
index 000000000..75dfd51d8
--- /dev/null
+++ b/tests/diagnostics/deprecation.slang
@@ -0,0 +1,60 @@
+//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
+
+// Here we test that diagnostics appear once per usage of each of the
+// deprecated declarations.
+
+[deprecated("please use foo(bool)")]
+void foo(int) {}
+
+void foo(bool) {}
+
+[deprecated("non-overloaded bar")]
+void bar() {}
+
+const float newPi = 3.1;
+
+[deprecated("more precise approximations are available elsewhere")]
+const int pi = 3;
+
+[deprecated("no")]
+struct Billiards
+{
+ [deprecated("puns")]
+ bool bs[22];
+}
+
+int main()
+{
+ pi;
+ // CHECK: tests/diagnostics/deprecation.slang([[#@LINE-1]]): warning 31200: pi has been deprecated: more precise approximations are available elsewhere
+ // CHECK-NEXT: pi;
+ // CHECK-NEXT: ^~
+
+ foo(0);
+ // CHECK: tests/diagnostics/deprecation.slang([[#@LINE-1]]): warning 31200: foo has been deprecated: please use foo(bool)
+ // CHECK-NEXT: foo(0);
+ // CHECK-NEXT: ^~~
+
+ foo(false); // doesn't warn
+ // CHECK-NOT: tests/diagnostics/deprecation.slang([[#@LINE-1]])
+
+ Billiards b;
+ // CHECK: tests/diagnostics/deprecation.slang([[#@LINE-1]]): warning 31200: Billiards has been deprecated: no
+ // CHECK-NEXT: Billiards b;
+ // CHECK-NEXT: ^~~~~~~~~
+
+ b.bs;
+ // CHECK: tests/diagnostics/deprecation.slang([[#@LINE-1]]): warning 31200: bs has been deprecated: puns
+ // CHECK-NEXT: b.bs;
+ // CHECK-NEXT: ^~
+
+ bar();
+ // CHECK: tests/diagnostics/deprecation.slang([[#@LINE-1]]): warning 31200: bar has been deprecated: non-overloaded bar
+ // CHECK-NEXT: bar();
+ // CHECK-NEXT: ^~~
+
+ // Check we don't have any extra warnings not caught by the above diagnostics
+ // CHECK-NOT: warning
+
+ return 0;
+}