1 // RUN: %clang_cc1 -DTEST1 -verify %s
2 // RUN: not %clang_cc1 -DTEST2 -verify %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
3 // RUN: not %clang_cc1 -DTEST3 -verify %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
4 // RUN: not %clang_cc1 -DTEST4 -verify %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
5 // RUN: not %clang_cc1 -DTEST5 -verify %s 2>&1 | FileCheck -check-prefix=CHECK5 %s
7 // expected-warning@ malformed
8 // expected-error@7 1 {{missing or invalid line number}}
10 // expected-warning@0 malformed
11 // expected-error@10 {{missing or invalid line number}}
13 // expected-warning@-50 malformed
14 // expected-error@13 {{missing or invalid line number}}
16 // expected-warning malformed
17 // expected-error@16 {{cannot find start}}
19 // expected-error 0+ {{should also be ignored}}
23 // expected-error {{should be ignored}}
25 // eexpected-error {{should also be ignored: unrecognised directive}}
26 #error should not be ignored
27 // expected-error@-1 1+ {{should not be ignored}}
30 unexpected a
; // expected-error@+0 + {{unknown type}}
33 unexpected b
; // expected-error@33 1-1 {{unknown type}}
35 // expected-error@+2 {{file not found}} check that multi-line handled correctly: \
37 #include "missing_header_file.include"
41 #define MACRO some_value // expected-error {{define_error}}
42 #undef MACRO extra_token // expected-warning {{undef_error}}
43 #line -2 // expected-error {{line_error}}
44 #error AAA // expected-error {{BBB}} <- this shall be part of diagnostic
45 #warning CCC // expected-warning {{DDD}} <- this shall be part of diagnostic
48 // This is encapsulated in "#if 0" so that the expected-* checks below
49 // are not inadvertently included in the diagnostic checking!
51 // CHECK2: error: 'expected-error' diagnostics expected but not seen:
52 // CHECK2-NEXT: Line 41: define_error
53 // CHECK2-NEXT: Line 43: line_error
54 // CHECK2-NEXT: error: 'expected-error' diagnostics seen but not expected:
55 // CHECK2-NEXT: Line 43: #line directive requires a positive integer argument
56 // CHECK2-NEXT: Line 44: AAA // expected-error {{[{][{]BBB[}][}]}} <- this shall be part of diagnostic
57 // CHECK2-NEXT: error: 'expected-warning' diagnostics expected but not seen:
58 // CHECK2-NEXT: Line 42: undef_error
59 // CHECK2-NEXT: error: 'expected-warning' diagnostics seen but not expected:
60 // CHECK2-NEXT: Line 42: extra tokens at end of #undef directive
61 // CHECK2-NEXT: Line 45: CCC // expected-warning {{[{][{]DDD[}][}]}} <- this shall be part of diagnostic
62 // CHECK2-NEXT: 7 errors generated.
67 #ifndef TEST3 // expected-note {{line_67}}
68 // expected-note {{line_68_ignored}}
69 # ifdef UNDEFINED // expected-note {{line_69_ignored}}
70 # endif // expected-note {{line_70_ignored}}
71 #elif defined(TEST3) // expected-note {{line_71}}
72 # if 1 // expected-note {{line_72}}
73 // expected-note {{line_73}}
74 # else // expected-note {{line_74}}
75 // expected-note {{line_75_ignored}}
76 # ifndef TEST3 // expected-note {{line_76_ignored}}
77 # endif // expected-note {{line_77_ignored}}
78 # endif // expected-note {{line_78}}
81 // CHECK3: error: 'expected-note' diagnostics expected but not seen:
82 // CHECK3-NEXT: Line 67: line_67
83 // CHECK3-NEXT: Line 71: line_71
84 // CHECK3-NEXT: Line 72: line_72
85 // CHECK3-NEXT: Line 73: line_73
86 // CHECK3-NEXT: Line 74: line_74
87 // CHECK3-NEXT: Line 78: line_78
88 // CHECK3-NEXT: 6 errors generated.
92 #include "missing_header_file.include" // expected-error {{include_error}}
94 // CHECK4: error: 'expected-error' diagnostics expected but not seen:
95 // CHECK4-NEXT: Line 92: include_error
96 // CHECK4-NEXT: error: 'expected-error' diagnostics seen but not expected:
97 // CHECK4-NEXT: Line 92: 'missing_header_file.include' file not found
98 // CHECK4-NEXT: 2 errors generated.
102 #include "verify-directive.h"
103 // expected-error@50 {{source file test}}
105 // CHECK5: error: 'expected-error' diagnostics expected but not seen:
106 // CHECK5-NEXT: Line 1 (directive at {{.*}}verify-directive.h:2): include file test
107 // CHECK5-NEXT: Line 50 (directive at {{.*}}verify.c:103): source file test
108 // CHECK5-NEXT: 2 errors generated.
112 // RUN: not %clang_cc1 -verify %t.invalid 2>&1 | FileCheck -check-prefix=CHECK6 %s
114 // CHECK6: error: no expected directives found: consider use of 'expected-no-diagnostics'
115 // CHECK6-NEXT: error: 'expected-error' diagnostics seen but not expected:
116 // CHECK6-NEXT: (frontend): error reading '{{.*}}verify.c.tmp.invalid'
117 // CHECK6-NEXT: 2 errors generated.
119 // RUN: printf '//expected-error@2{{1}}\n#error 2\n' | not %clang_cc1 -verify 2>&1 | FileCheck -check-prefix=CHECK7 %s
121 // CHECK7: error: 'expected-error' diagnostics expected but not seen:
122 // CHECK7-NEXT: Line 2 (directive at <stdin>:1): 1
123 // CHECK7-NEXT: error: 'expected-error' diagnostics seen but not expected:
124 // CHECK7-NEXT: Line 2: 2
125 // CHECK7-NEXT: 2 errors generated.
129 // RUN: not %clang_cc1 -DTEST8 -verify %s 2>&1 | FileCheck -check-prefix=CHECK8 %s
131 // expected-warning@nonexistent-file:1 {{ }}
132 // expected-error@-1 {{file 'nonexistent-file' could not be located}}
134 // expected-warning@verify-directive.h: {{ }}
135 // expected-error@-1 {{missing or invalid line number}}
137 // expected-warning@verify-directive.h:0 {{ }}
138 // expected-error@-1 {{missing or invalid line number}}
140 // expected-warning@verify-directive.h:0*{{ }}
141 // expected-error@-1 {{missing or invalid line number}}
143 // expected-warning@verify-directive.h:*0{{ }}
144 // syntactically ok -- means match in any line for 0 occurrences.
146 // expected-warning@verify-directive.h:1 {{diagnostic}}
148 // CHECK8: error: 'expected-warning' diagnostics expected but not seen:
149 // CHECK8-NEXT: File {{.*}}verify-directive.h Line 1 (directive at {{.*}}verify.c:146): diagnostic
150 // CHECK8-NEXT: 1 error generated.
155 // RUN: not %clang_cc1 -DTEST9 -verify=what %s 2>&1 | FileCheck -check-prefix=CHECK9 %s
157 // what-error {{huh?}}
158 // CHECK9: error: 'what-error' diagnostics expected but not seen:
161 #ifdef TEST_WIDE_DELIM
162 // RUN: not %clang_cc1 -DTEST_WIDE_DELIM -verify %s 2>&1 | FileCheck -check-prefix=CHECK-WIDE-DELIM %s
164 // expected-error {{{some message with {{}} in it}}}
165 // expected-error {{{some message with {}} in it}}}
166 // expected-error {{{some message with {{} in it}}}
168 // expected-error-re {{{some {{.*}} regex with double braces}}}
169 // expected-error-re {{{some message with {{} in it}}}
171 // expected-error {{{mismatched delim}}
172 // expected-error-re {{{mismatched re {{.*} }}}
173 // expected-error-re {{{no regex}}}
176 // CHECK-WIDE-DELIM: error: 'expected-error' diagnostics expected but not seen:
177 // CHECK-WIDE-DELIM-NEXT: verify.c Line 164: some message with {{[{]{}[}]}} in it
178 // CHECK-WIDE-DELIM-NEXT: verify.c Line 165: some message with {}} in it
179 // CHECK-WIDE-DELIM-NEXT: verify.c Line 166: some message with {{[{]{[}]}} in it
180 // CHECK-WIDE-DELIM-NEXT: verify.c Line 168: {some {{.*}} regex with double braces
181 // CHECK-WIDE-DELIM-NEXT: error: 'expected-error' diagnostics seen but not expected:
182 // CHECK-WIDE-DELIM-NEXT: verify.c Line 169: cannot find end ('}}') of expected regex
183 // CHECK-WIDE-DELIM-NEXT: verify.c Line 171: cannot find end ('}}}') of expected string
184 // CHECK-WIDE-DELIM-NEXT: verify.c Line 172: cannot find end ('}}') of expected regex
185 // CHECK-WIDE-DELIM-NEXT: verify.c Line 173: cannot find start of regex ('{{[{][{]}}') in {no regex
186 // CHECK-WIDE-DELIM-NEXT: 8 errors generated.
192 // RUN: not %clang_cc1 -DTEST10 -verify=foo %s 2>&1 | FileCheck -check-prefix=CHECK10 %s
194 // CHECK10: error: no expected directives found: consider use of 'foo-no-diagnostics'
198 // RUN: not %clang_cc1 -DTEST11 -verify=foo %s 2>&1 | FileCheck -check-prefix=CHECK11 %s
200 // foo-no-diagnostics
203 // CHECK11: error: 'foo-error' diagnostics seen but not expected:
204 // CHECK11-NEXT: Line 201: expected directive cannot follow 'foo-no-diagnostics' directive
205 // CHECK11-NEXT: 1 error generated.
209 // RUN: not %clang_cc1 -DTEST12 -verify=foo %s 2>&1 | FileCheck -check-prefix=CHECK12 %s
212 // foo-warning@-1 {{X}}
213 // foo-no-diagnostics
215 // CHECK12: error: 'foo-error' diagnostics seen but not expected:
216 // CHECK12-NEXT: Line 213: 'foo-no-diagnostics' directive cannot follow other expected directives
217 // CHECK12-NEXT: 1 error generated.