• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
6 
7 // expected-warning@ malformed
8 // expected-error@7 1 {{missing or invalid line number}}
9 
10 // expected-warning@0 malformed
11 // expected-error@10 {{missing or invalid line number}}
12 
13 // expected-warning@-50 malformed
14 // expected-error@13 {{missing or invalid line number}}
15 
16 // expected-warning malformed
17 // expected-error@16 {{cannot find start}}
18 
19 // expected-error 0+ {{should also be ignored}}
20 
21 #ifdef TEST1
22 #if 0
23 // expected-error {{should be ignored}}
24 #endif
25 // eexpected-error {{should also be ignored: unrecognised directive}}
26 #error should not be ignored
27 // expected-error@-1 1+ {{should not be ignored}}
28 
29 #line 90
30 unexpected a; // expected-error@+0 + {{unknown type}}
31 
32 #line 60
33 unexpected b; // expected-error@33 1-1 {{unknown type}}
34 
35 // expected-error@+2 {{file not found}} check that multi-line handled correctly: \
36 
37 #include "missing_header_file.include"
38 #endif
39 
40 #ifdef TEST2
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
46 
47 #if 0
48 // This is encapsulated in "#if 0" so that the expected-* checks below
49 // are not inadvertently included in the diagnostic checking!
50 
51 //      CHECK2: error: 'error' diagnostics expected but not seen:
52 // CHECK2-NEXT:   Line 41: define_error
53 // CHECK2-NEXT:   Line 43: line_error
54 // CHECK2-NEXT: error: '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: 'warning' diagnostics expected but not seen:
58 // CHECK2-NEXT:   Line 42: undef_error
59 // CHECK2-NEXT: error: '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.
63 #endif
64 #endif
65 
66 #ifdef TEST3
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}}
79 #endif
80 
81 //      CHECK3: error: '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.
89 #endif
90 
91 #ifdef TEST4
92 #include "missing_header_file.include" // expected-error {{include_error}}
93 
94 //      CHECK4: error: 'error' diagnostics expected but not seen:
95 // CHECK4-NEXT:   Line 92: include_error
96 // CHECK4-NEXT: error: 'error' diagnostics seen but not expected:
97 // CHECK4-NEXT:   Line 92: 'missing_header_file.include' file not found
98 // CHECK4-NEXT: 2 errors generated.
99 #endif
100 
101 #ifdef TEST5
102 #include "verify-directive.h"
103 // expected-error@50 {{source file test}}
104 
105 //      CHECK5: error: '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.
109 #endif
110 
111 #if 0
112 // RUN: not %clang_cc1 -verify %t.invalid 2>&1 | FileCheck -check-prefix=CHECK6 %s
113 
114 //      CHECK6: error: no expected directives found: consider use of 'expected-no-diagnostics'
115 // CHECK6-NEXT: error: 'error' diagnostics seen but not expected:
116 // CHECK6-NEXT:   (frontend): error reading '{{.*}}verify.c.tmp.invalid'
117 // CHECK6-NEXT: 2 errors generated.
118 
119 // RUN: printf '//expected-error@2{{1}}\n#error 2\n' | not %clang_cc1 -verify 2>&1 | FileCheck -check-prefix=CHECK7 %s
120 
121 //      CHECK7: error: 'error' diagnostics expected but not seen:
122 // CHECK7-NEXT:   Line 2 (directive at <stdin>:1): 1
123 // CHECK7-NEXT: error: 'error' diagnostics seen but not expected:
124 // CHECK7-NEXT:   Line 2: 2
125 // CHECK7-NEXT: 2 errors generated.
126 #endif
127 
128 #ifdef TEST8
129 // RUN: not %clang_cc1 -DTEST8 -verify %s 2>&1 | FileCheck -check-prefix=CHECK8 %s
130 
131 // expected-warning@nonexistent-file:1 {{ }}
132 // expected-error@-1 {{file 'nonexistent-file' could not be located}}
133 
134 // expected-warning@verify-directive.h: {{ }}
135 // expected-error@-1 {{missing or invalid line number}}
136 
137 // expected-warning@verify-directive.h:0 {{ }}
138 // expected-error@-1 {{missing or invalid line number}}
139 
140 // expected-warning@verify-directive.h:0*{{ }}
141 // expected-error@-1 {{missing or invalid line number}}
142 
143 // expected-warning@verify-directive.h:*0{{ }}
144 // syntactically ok -- means match in any line for 0 occurrences.
145 
146 // expected-warning@verify-directive.h:1 {{diagnostic}}
147 
148 //      CHECK8: error: '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.
151 #endif
152