aboutsummaryrefslogtreecommitdiff
path: root/test/Frontend/verify3.c
diff options
context:
space:
mode:
authorAndy Gibbs <andyg1001@hotmail.co.uk>2012-10-19 12:49:32 +0000
committerAndy Gibbs <andyg1001@hotmail.co.uk>2012-10-19 12:49:32 +0000
commit266dba3661928d26f043560b169bea87578aa917 (patch)
tree0c8f3042a1255fb78437c4e239921fd92fe30a96 /test/Frontend/verify3.c
parent8e8fb3be5bd78f0564444eca02b404566a5f3b5d (diff)
Change VerifyDiagnosticConsumer so that it *must* contain at least one "expected-*" directive. As a result, for test-cases that are not expected to generate any diagnostics, an additional directive "expected-no-diagnostics" has been implemented which can then be included in such test-cases. This new directive may not be used in conjunction with any other "expected-*" directive.
This change was initially proposed as a solution to the problem highlighted by check-in r164677, i.e. that -verify will not cause a test-case failure where the compile command does not actually reference the file. Patch reviewed by David Blaikie. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166281 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Frontend/verify3.c')
-rw-r--r--test/Frontend/verify3.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/Frontend/verify3.c b/test/Frontend/verify3.c
new file mode 100644
index 0000000000..0705b4b7ee
--- /dev/null
+++ b/test/Frontend/verify3.c
@@ -0,0 +1,41 @@
+// This test-case runs several sub-tests on -verify to ensure that correct
+// diagnostics are generated in relation to the mis-use and non-use of the
+// 'expected-no-diagnostics' directive.
+
+// RUN: %clang_cc1 -DTEST1 -verify %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
+#ifdef TEST1
+// expected-no-diagnostics
+// expected-note {{}}
+
+// CHECK1: error: 'error' diagnostics seen but not expected:
+// CHECK1-NEXT: Line 8: expected directive cannot follow 'expected-no-diagnostics' directive
+// CHECK1-NEXT: 1 error generated.
+#endif
+
+// RUN: %clang_cc1 -DTEST2 -verify %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
+#ifdef TEST2
+#warning X
+// expected-warning@-1 {{X}}
+// expected-no-diagnostics
+
+// CHECK2: error: 'error' diagnostics seen but not expected:
+// CHECK2-NEXT: Line 19: 'expected-no-diagnostics' directive cannot follow other expected directives
+// CHECK2-NEXT: 1 error generated.
+#endif
+
+// RUN: %clang_cc1 -DTEST3 -verify %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
+// RUN: %clang_cc1 -verify 2>&1 | FileCheck -check-prefix=CHECK3 %s
+#ifdef TEST3
+// no directives
+
+// CHECK3: error: no expected directives found: consider use of 'expected-no-diagnostics'
+// CHECK3-NEXT: 1 error generated.
+#endif
+
+// RUN: %clang_cc1 -E -DTEST4 -verify %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
+#ifdef TEST4
+#warning X
+// expected-warning@-1 {{X}}
+
+// CHECK4-NOT: error: no expected directives found: consider use of 'expected-no-diagnostics'
+#endif