diff options
author | Andy Gibbs <andyg1001@hotmail.co.uk> | 2012-10-19 12:49:32 +0000 |
---|---|---|
committer | Andy Gibbs <andyg1001@hotmail.co.uk> | 2012-10-19 12:49:32 +0000 |
commit | 266dba3661928d26f043560b169bea87578aa917 (patch) | |
tree | 0c8f3042a1255fb78437c4e239921fd92fe30a96 /test/Frontend | |
parent | 8e8fb3be5bd78f0564444eca02b404566a5f3b5d (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')
-rw-r--r-- | test/Frontend/verify.c | 5 | ||||
-rw-r--r-- | test/Frontend/verify2.c | 7 | ||||
-rw-r--r-- | test/Frontend/verify3.c | 41 |
3 files changed, 48 insertions, 5 deletions
diff --git a/test/Frontend/verify.c b/test/Frontend/verify.c index 8b4edc5a76..062e6bd861 100644 --- a/test/Frontend/verify.c +++ b/test/Frontend/verify.c @@ -111,9 +111,10 @@ unexpected b; // expected-error@33 1-1 {{unknown type}} #if 0 // RUN: %clang_cc1 -verify %t.invalid 2>&1 | FileCheck -check-prefix=CHECK6 %s -// CHECK6: error: 'error' diagnostics seen but not expected: +// CHECK6: error: no expected directives found: consider use of 'expected-no-diagnostics' +// CHECK6-NEXT: error: 'error' diagnostics seen but not expected: // CHECK6-NEXT: (frontend): error reading '{{.*}}verify.c.tmp.invalid' -// CHECK6-NEXT: 1 error generated. +// CHECK6-NEXT: 2 errors generated. // RUN: echo -e '//expected-error@2{{1}}\n#error 2' | %clang_cc1 -verify 2>&1 | FileCheck -check-prefix=CHECK7 %s diff --git a/test/Frontend/verify2.c b/test/Frontend/verify2.c index a1c797581e..04f80ad48e 100644 --- a/test/Frontend/verify2.c +++ b/test/Frontend/verify2.c @@ -3,7 +3,7 @@ // Please note that all comments are inside "#if 0" blocks so that // VerifyDiagnosticConsumer sees no comments while processing this -// test-case. +// test-case (and hence no expected-* directives). #endif #include "verify2.h" @@ -12,8 +12,9 @@ #if 0 // expected-error {{should be ignored}} -// CHECK: error: 'error' diagnostics seen but not expected: +// CHECK: error: no expected directives found: consider use of 'expected-no-diagnostics' +// CHECK-NEXT: error: 'error' diagnostics seen but not expected: // CHECK-NEXT: Line 1: header // CHECK-NEXT: Line 10: source -// CHECK-NEXT: 2 errors generated. +// CHECK-NEXT: 3 errors generated. #endif 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 |