xref: /minix3/external/bsd/llvm/dist/clang/test/Frontend/verify.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -DTEST1 -verify %s
2f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -DTEST2 -verify %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
3f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -DTEST3 -verify %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
4f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -DTEST4 -verify %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
5f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -DTEST5 -verify %s 2>&1 | FileCheck -check-prefix=CHECK5 %s
6f4a2713aSLionel Sambuc 
7f4a2713aSLionel Sambuc // expected-warning@ malformed
8f4a2713aSLionel Sambuc // expected-error@7 1 {{missing or invalid line number}}
9f4a2713aSLionel Sambuc 
10f4a2713aSLionel Sambuc // expected-warning@0 malformed
11f4a2713aSLionel Sambuc // expected-error@10 {{missing or invalid line number}}
12f4a2713aSLionel Sambuc 
13f4a2713aSLionel Sambuc // expected-warning@-50 malformed
14f4a2713aSLionel Sambuc // expected-error@13 {{missing or invalid line number}}
15f4a2713aSLionel Sambuc 
16f4a2713aSLionel Sambuc // expected-warning malformed
17f4a2713aSLionel Sambuc // expected-error@16 {{cannot find start}}
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc // expected-error 0+ {{should also be ignored}}
20f4a2713aSLionel Sambuc 
21f4a2713aSLionel Sambuc #ifdef TEST1
22f4a2713aSLionel Sambuc #if 0
23f4a2713aSLionel Sambuc // expected-error {{should be ignored}}
24f4a2713aSLionel Sambuc #endif
25f4a2713aSLionel Sambuc // eexpected-error {{should also be ignored: unrecognised directive}}
26f4a2713aSLionel Sambuc #error should not be ignored
27f4a2713aSLionel Sambuc // expected-error@-1 1+ {{should not be ignored}}
28f4a2713aSLionel Sambuc 
29f4a2713aSLionel Sambuc #line 90
30f4a2713aSLionel Sambuc unexpected a; // expected-error@+0 + {{unknown type}}
31f4a2713aSLionel Sambuc 
32f4a2713aSLionel Sambuc #line 60
33f4a2713aSLionel Sambuc unexpected b; // expected-error@33 1-1 {{unknown type}}
34f4a2713aSLionel Sambuc 
35f4a2713aSLionel Sambuc // expected-error@+2 {{file not found}} check that multi-line handled correctly: \
36f4a2713aSLionel Sambuc 
37f4a2713aSLionel Sambuc #include "missing_header_file.include"
38f4a2713aSLionel Sambuc #endif
39f4a2713aSLionel Sambuc 
40f4a2713aSLionel Sambuc #ifdef TEST2
41f4a2713aSLionel Sambuc #define MACRO some_value // expected-error {{define_error}}
42f4a2713aSLionel Sambuc #undef MACRO extra_token // expected-warning {{undef_error}}
43f4a2713aSLionel Sambuc #line -2                 // expected-error {{line_error}}
44f4a2713aSLionel Sambuc #error AAA               // expected-error {{BBB}} <- this shall be part of diagnostic
45f4a2713aSLionel Sambuc #warning CCC             // expected-warning {{DDD}} <- this shall be part of diagnostic
46f4a2713aSLionel Sambuc 
47f4a2713aSLionel Sambuc #if 0
48f4a2713aSLionel Sambuc // This is encapsulated in "#if 0" so that the expected-* checks below
49f4a2713aSLionel Sambuc // are not inadvertently included in the diagnostic checking!
50f4a2713aSLionel Sambuc 
51f4a2713aSLionel Sambuc //      CHECK2: error: 'error' diagnostics expected but not seen:
52f4a2713aSLionel Sambuc // CHECK2-NEXT:   Line 41: define_error
53f4a2713aSLionel Sambuc // CHECK2-NEXT:   Line 43: line_error
54f4a2713aSLionel Sambuc // CHECK2-NEXT: error: 'error' diagnostics seen but not expected:
55f4a2713aSLionel Sambuc // CHECK2-NEXT:   Line 43: #line directive requires a positive integer argument
56f4a2713aSLionel Sambuc // CHECK2-NEXT:   Line 44: AAA // expected-error {{[{][{]BBB[}][}]}} <- this shall be part of diagnostic
57f4a2713aSLionel Sambuc // CHECK2-NEXT: error: 'warning' diagnostics expected but not seen:
58f4a2713aSLionel Sambuc // CHECK2-NEXT:   Line 42: undef_error
59f4a2713aSLionel Sambuc // CHECK2-NEXT: error: 'warning' diagnostics seen but not expected:
60f4a2713aSLionel Sambuc // CHECK2-NEXT:   Line 42: extra tokens at end of #undef directive
61f4a2713aSLionel Sambuc // CHECK2-NEXT:   Line 45: CCC // expected-warning {{[{][{]DDD[}][}]}} <- this shall be part of diagnostic
62f4a2713aSLionel Sambuc // CHECK2-NEXT: 7 errors generated.
63f4a2713aSLionel Sambuc #endif
64f4a2713aSLionel Sambuc #endif
65f4a2713aSLionel Sambuc 
66f4a2713aSLionel Sambuc #ifdef TEST3
67f4a2713aSLionel Sambuc #ifndef TEST3         // expected-note {{line_67}}
68f4a2713aSLionel Sambuc                       // expected-note {{line_68_ignored}}
69f4a2713aSLionel Sambuc # ifdef UNDEFINED     // expected-note {{line_69_ignored}}
70f4a2713aSLionel Sambuc # endif               // expected-note {{line_70_ignored}}
71f4a2713aSLionel Sambuc #elif defined(TEST3)  // expected-note {{line_71}}
72f4a2713aSLionel Sambuc # if 1                // expected-note {{line_72}}
73f4a2713aSLionel Sambuc                       // expected-note {{line_73}}
74f4a2713aSLionel Sambuc # else                // expected-note {{line_74}}
75f4a2713aSLionel Sambuc                       // expected-note {{line_75_ignored}}
76f4a2713aSLionel Sambuc #  ifndef TEST3       // expected-note {{line_76_ignored}}
77f4a2713aSLionel Sambuc #  endif              // expected-note {{line_77_ignored}}
78f4a2713aSLionel Sambuc # endif               // expected-note {{line_78}}
79f4a2713aSLionel Sambuc #endif
80f4a2713aSLionel Sambuc 
81f4a2713aSLionel Sambuc //      CHECK3: error: 'note' diagnostics expected but not seen:
82f4a2713aSLionel Sambuc // CHECK3-NEXT:   Line 67: line_67
83f4a2713aSLionel Sambuc // CHECK3-NEXT:   Line 71: line_71
84f4a2713aSLionel Sambuc // CHECK3-NEXT:   Line 72: line_72
85f4a2713aSLionel Sambuc // CHECK3-NEXT:   Line 73: line_73
86f4a2713aSLionel Sambuc // CHECK3-NEXT:   Line 74: line_74
87f4a2713aSLionel Sambuc // CHECK3-NEXT:   Line 78: line_78
88f4a2713aSLionel Sambuc // CHECK3-NEXT: 6 errors generated.
89f4a2713aSLionel Sambuc #endif
90f4a2713aSLionel Sambuc 
91f4a2713aSLionel Sambuc #ifdef TEST4
92f4a2713aSLionel Sambuc #include "missing_header_file.include" // expected-error {{include_error}}
93f4a2713aSLionel Sambuc 
94f4a2713aSLionel Sambuc //      CHECK4: error: 'error' diagnostics expected but not seen:
95f4a2713aSLionel Sambuc // CHECK4-NEXT:   Line 92: include_error
96f4a2713aSLionel Sambuc // CHECK4-NEXT: error: 'error' diagnostics seen but not expected:
97f4a2713aSLionel Sambuc // CHECK4-NEXT:   Line 92: 'missing_header_file.include' file not found
98f4a2713aSLionel Sambuc // CHECK4-NEXT: 2 errors generated.
99f4a2713aSLionel Sambuc #endif
100f4a2713aSLionel Sambuc 
101f4a2713aSLionel Sambuc #ifdef TEST5
102f4a2713aSLionel Sambuc #include "verify-directive.h"
103f4a2713aSLionel Sambuc // expected-error@50 {{source file test}}
104f4a2713aSLionel Sambuc 
105f4a2713aSLionel Sambuc //      CHECK5: error: 'error' diagnostics expected but not seen:
106f4a2713aSLionel Sambuc // CHECK5-NEXT:   Line 1 (directive at {{.*}}verify-directive.h:2): include file test
107f4a2713aSLionel Sambuc // CHECK5-NEXT:   Line 50 (directive at {{.*}}verify.c:103): source file test
108f4a2713aSLionel Sambuc // CHECK5-NEXT: 2 errors generated.
109f4a2713aSLionel Sambuc #endif
110f4a2713aSLionel Sambuc 
111f4a2713aSLionel Sambuc #if 0
112f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -verify %t.invalid 2>&1 | FileCheck -check-prefix=CHECK6 %s
113f4a2713aSLionel Sambuc 
114f4a2713aSLionel Sambuc //      CHECK6: error: no expected directives found: consider use of 'expected-no-diagnostics'
115f4a2713aSLionel Sambuc // CHECK6-NEXT: error: 'error' diagnostics seen but not expected:
116f4a2713aSLionel Sambuc // CHECK6-NEXT:   (frontend): error reading '{{.*}}verify.c.tmp.invalid'
117f4a2713aSLionel Sambuc // CHECK6-NEXT: 2 errors generated.
118f4a2713aSLionel Sambuc 
119f4a2713aSLionel Sambuc // RUN: printf '//expected-error@2{{1}}\n#error 2\n' | not %clang_cc1 -verify 2>&1 | FileCheck -check-prefix=CHECK7 %s
120f4a2713aSLionel Sambuc 
121f4a2713aSLionel Sambuc //      CHECK7: error: 'error' diagnostics expected but not seen:
122f4a2713aSLionel Sambuc // CHECK7-NEXT:   Line 2 (directive at <stdin>:1): 1
123f4a2713aSLionel Sambuc // CHECK7-NEXT: error: 'error' diagnostics seen but not expected:
124f4a2713aSLionel Sambuc // CHECK7-NEXT:   Line 2: 2
125f4a2713aSLionel Sambuc // CHECK7-NEXT: 2 errors generated.
126f4a2713aSLionel Sambuc #endif
127f4a2713aSLionel Sambuc 
128f4a2713aSLionel Sambuc #ifdef TEST8
129f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -DTEST8 -verify %s 2>&1 | FileCheck -check-prefix=CHECK8 %s
130f4a2713aSLionel Sambuc 
131f4a2713aSLionel Sambuc // expected-warning@nonexistent-file:1 {{ }}
132f4a2713aSLionel Sambuc // expected-error@-1 {{file 'nonexistent-file' could not be located}}
133f4a2713aSLionel Sambuc 
134f4a2713aSLionel Sambuc // expected-warning@verify-directive.h: {{ }}
135f4a2713aSLionel Sambuc // expected-error@-1 {{missing or invalid line number}}
136f4a2713aSLionel Sambuc 
137*0a6a1f1dSLionel Sambuc // expected-warning@verify-directive.h:0 {{ }}
138*0a6a1f1dSLionel Sambuc // expected-error@-1 {{missing or invalid line number}}
139*0a6a1f1dSLionel Sambuc 
140*0a6a1f1dSLionel Sambuc // expected-warning@verify-directive.h:0*{{ }}
141*0a6a1f1dSLionel Sambuc // expected-error@-1 {{missing or invalid line number}}
142*0a6a1f1dSLionel Sambuc 
143*0a6a1f1dSLionel Sambuc // expected-warning@verify-directive.h:*0{{ }}
144*0a6a1f1dSLionel Sambuc // syntactically ok -- means match in any line for 0 occurrences.
145*0a6a1f1dSLionel Sambuc 
146f4a2713aSLionel Sambuc // expected-warning@verify-directive.h:1 {{diagnostic}}
147f4a2713aSLionel Sambuc 
148f4a2713aSLionel Sambuc //      CHECK8: error: 'warning' diagnostics expected but not seen:
149*0a6a1f1dSLionel Sambuc // CHECK8-NEXT:   File {{.*}}verify-directive.h Line 1 (directive at {{.*}}verify.c:146): diagnostic
150f4a2713aSLionel Sambuc // CHECK8-NEXT: 1 error generated.
151f4a2713aSLionel Sambuc #endif
152