summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-11-11 09:56:50 -0500
committerGitHub <noreply@github.com>2020-11-11 09:56:50 -0500
commit8f0895e0f8257da2fd10b6325931627a9a1792ba (patch)
tree448c221583fe160df70a2e90fd2c8b80b82634b6 /tests
parent7bcc2b15c8be4aebc6b9b8f05af6db7a451b228b (diff)
Include hierarchy output (#1595)
* #include an absolute path didn't work - because paths were taken to always be relative. * Improve diagnostic for token pasting. * Token paste location test. * Output include hierarchy. * WIP on includes hierarchy. * Improved include hierarchy output - to handle source files without tokens. Improved test case. * Small comment improvements. Fixed a typo with not returning a reference. * Slight simplification of the ViewInitiatingHierarchy, by adding GetOrAddValue to Dictionary. * Remove the need for ViewInitiatingHierarchy type. * Improve output of path in diagnostic for includes hierarchy. * Remove comment in diagnostic for token-paste-location.slang * Update command line docs to include `-output-includes` Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/diagnostics/token-paste-location.slang14
-rw-r--r--tests/diagnostics/token-paste-location.slang.expected7
-rw-r--r--tests/preprocessor/include/include-pragma-once-c.h5
-rw-r--r--tests/preprocessor/output-includes.slang10
-rw-r--r--tests/preprocessor/output-includes.slang.expected15
5 files changed, 51 insertions, 0 deletions
diff --git a/tests/diagnostics/token-paste-location.slang b/tests/diagnostics/token-paste-location.slang
new file mode 100644
index 000000000..4da66bab3
--- /dev/null
+++ b/tests/diagnostics/token-paste-location.slang
@@ -0,0 +1,14 @@
+//DIAGNOSTIC_TEST:SIMPLE:
+
+
+#define SOME %
+#define THING %
+
+#define A SOME
+#define B THING
+
+#define PASTE2(x, y) x##y
+#define PASTE(x, y) PASTE2(x, y)
+
+
+PASTE(A, B)
diff --git a/tests/diagnostics/token-paste-location.slang.expected b/tests/diagnostics/token-paste-location.slang.expected
new file mode 100644
index 000000000..e8f689a45
--- /dev/null
+++ b/tests/diagnostics/token-paste-location.slang.expected
@@ -0,0 +1,7 @@
+result code = -1
+standard error = {
+token paste(1): error 20001: unexpected '%', expected identifier
+tests/diagnostics/token-paste-location.slang(10): note: see token pasted location
+}
+standard output = {
+}
diff --git a/tests/preprocessor/include/include-pragma-once-c.h b/tests/preprocessor/include/include-pragma-once-c.h
new file mode 100644
index 000000000..5c07d2846
--- /dev/null
+++ b/tests/preprocessor/include/include-pragma-once-c.h
@@ -0,0 +1,5 @@
+// include-pragma-once-c.h
+
+#pragma once
+
+#include "pragma-once-c.h" \ No newline at end of file
diff --git a/tests/preprocessor/output-includes.slang b/tests/preprocessor/output-includes.slang
new file mode 100644
index 000000000..9e40056ed
--- /dev/null
+++ b/tests/preprocessor/output-includes.slang
@@ -0,0 +1,10 @@
+//DIAGNOSTIC_TEST:SIMPLE:-output-includes
+
+int foo() { return 0; }
+
+#include "include-a.slang.h"
+#include "include/include-pragma-once-c.h"
+#include "../preprocessor/include-a.slang.h"
+#include "./include-a.slang.h"
+
+int baz() { return bar(); } \ No newline at end of file
diff --git a/tests/preprocessor/output-includes.slang.expected b/tests/preprocessor/output-includes.slang.expected
new file mode 100644
index 000000000..791621aa3
--- /dev/null
+++ b/tests/preprocessor/output-includes.slang.expected
@@ -0,0 +1,15 @@
+result code = -1
+standard error = {
+(0): note: include 'tests/preprocessor/output-includes.slang'
+(0): note: include 'tests/preprocessor/include-a.slang.h'
+(0): note: include 'tests/preprocessor/include/include-pragma-once-c.h'
+(0): note: include 'tests/preprocessor/include/pragma-once-c.h'
+(0): note: include 'tests/preprocessor/include-a.slang.h'
+(0): note: include 'tests/preprocessor/include-a.slang.h'
+tests/preprocessor/include-a.slang.h(3): error 30201: function 'bar' already has a body
+tests/preprocessor/include-a.slang.h(3): note: see previous definition of 'bar'
+tests/preprocessor/include-a.slang.h(3): error 30201: function 'bar' already has a body
+tests/preprocessor/include-a.slang.h(3): note: see previous definition of 'bar'
+}
+standard output = {
+}