1 // RUN: not %clang_cc1 -std=c++11 -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines=5 -Wsometimes-uninitialized %s 2>&1 | FileCheck %s --strict-whitespace
5 // Check we expand the range as much as possible within the limit.
7 // CHECK: warning: variable 'a' is used uninitialized whenever 'if' condition is true
8 // CHECK-NEXT: {{^}} if (cond) {
9 // CHECK-NEXT: {{^}} ^~~~{{$}}
10 // CHECK-NEXT: note: uninitialized use occurs here
11 // CHECK-NEXT: {{^}} return a;
12 // CHECK-NEXT: {{^}} ^
13 // CHECK-NEXT: note: remove the 'if' if its condition is always false
14 // CHECK-NEXT: {{^}} if (cond) {
15 // CHECK-NEXT: {{^}} ^~~~~~~~~~~{{$}}
16 // CHECK-NEXT: {{^}} line(1);
17 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
18 // CHECK-NEXT: {{^}} } else {
19 // CHECK-NEXT: {{^}} ~~~~~~{{$}}
20 // CHECK-NEXT: note: initialize the variable
31 // CHECK: warning: variable 'a' is used uninitialized whenever 'if' condition is true
32 // CHECK-NEXT: {{^}} if (cond) {
33 // CHECK-NEXT: {{^}} ^~~~{{$}}
34 // CHECK-NEXT: note: uninitialized use occurs here
35 // CHECK-NEXT: {{^}} return a;
36 // CHECK-NEXT: {{^}} ^
37 // CHECK-NEXT: note: remove the 'if' if its condition is always false
38 // CHECK-NEXT: {{^}} if (cond) {
39 // CHECK-NEXT: {{^}} ^~~~~~~~~~~{{$}}
40 // CHECK-NEXT: {{^}} line(1);
41 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
42 // CHECK-NEXT: {{^}} line(2);
43 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
44 // CHECK-NEXT: {{^}} } else {
45 // CHECK-NEXT: {{^}} ~~~~~~{{$}}
46 // CHECK-NEXT: note: initialize the variable
58 // CHECK: warning: variable 'a' is used uninitialized whenever 'if' condition is true
59 // CHECK-NEXT: {{^}} if (cond) {
60 // CHECK-NEXT: {{^}} ^~~~{{$}}
61 // CHECK-NEXT: note: uninitialized use occurs here
62 // CHECK-NEXT: {{^}} return a;
63 // CHECK-NEXT: {{^}} ^
64 // CHECK-NEXT: note: remove the 'if' if its condition is always false
65 // CHECK-NEXT: {{^}} if (cond) {
66 // CHECK-NEXT: {{^}} ^~~~~~~~~~~{{$}}
67 // CHECK-NEXT: {{^}} line(1);
68 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
69 // CHECK-NEXT: {{^}} line(2);
70 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
71 // CHECK-NEXT: {{^}} line(3);
72 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
73 // CHECK-NEXT: {{^}} } else {
74 // CHECK-NEXT: {{^}} ~~~~~~{{$}}
75 // CHECK-NEXT: note: initialize the variable
88 // CHECK: warning: variable 'a' is used uninitialized whenever 'if' condition is true
89 // CHECK-NEXT: {{^}} if (cond) {
90 // CHECK-NEXT: {{^}} ^~~~{{$}}
91 // CHECK-NEXT: note: uninitialized use occurs here
92 // CHECK-NEXT: {{^}} return a;
93 // CHECK-NEXT: {{^}} ^
94 // CHECK-NEXT: note: remove the 'if' if its condition is always false
95 // CHECK-NEXT: {{^}} if (cond) {
96 // CHECK-NEXT: {{^}} ^~~~~~~~~~~{{$}}
97 // CHECK-NEXT: {{^}} line(1);
98 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
99 // CHECK-NEXT: {{^}} line(2);
100 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
101 // CHECK-NEXT: {{^}} line(3);
102 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
103 // CHECK-NEXT: {{^}} line(4);
104 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
105 // CHECK-NEXT: note: initialize the variable
119 // CHECK: warning: variable 'a' is used uninitialized whenever 'if' condition is true
120 // CHECK-NEXT: {{^}} if (cond) {
121 // CHECK-NEXT: {{^}} ^~~~{{$}}
122 // CHECK-NEXT: note: uninitialized use occurs here
123 // CHECK-NEXT: {{^}} return a;
124 // CHECK-NEXT: {{^}} ^
125 // CHECK-NEXT: note: remove the 'if' if its condition is always false
126 // CHECK-NEXT: {{^}} if (cond) {
127 // CHECK-NEXT: {{^}} ^~~~~~~~~~~{{$}}
128 // CHECK-NEXT: {{^}} line(1);
129 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
130 // CHECK-NEXT: {{^}} line(2);
131 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
132 // CHECK-NEXT: {{^}} line(3);
133 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
134 // CHECK-NEXT: {{^}} line(4);
135 // CHECK-NEXT: {{^}} ~~~~~~~~{{$}}
136 // CHECK-NEXT: note: initialize the variable
152 // Check that we don't include lines with no interesting code if we can't reach
153 // the interesting part within the line limit.
155 // CHECK: error: no matching function for call to 'g
157 // CHECK: note: candidate template ignored: substitution failure
158 // CHECK-NEXT: {{^}}decltype(T()
159 // CHECK-NEXT: {{^}} ~{{$}}
160 // CHECK-NEXT: {{^}} + 1
161 // CHECK-NEXT: {{^}} + 2
162 // CHECK-NEXT: {{^}} + 3
163 // CHECK-NEXT: {{^}}void g();
164 // CHECK-NEXT: {{^}} ^{{$}}
172 // CHECK: note: candidate template ignored: substitution failure
173 // CHECK-NEXT: {{^}}void g();
174 // CHECK-NEXT: {{^}} ^{{$}}
183 void h() { g
<int()>(); }
186 void multiple_ranges(int a
, int b
) {
187 // CHECK: error: invalid operands
198 // CHECK-NEXT: error: invalid operands
217 // CHECK-NEXT: error: invalid operands
236 #define pr33902_a(b) #b
237 #define pr33902_c(d) _Pragma(pr33902_a(d))
238 #define pr33902_e(f) pr33902_c(GCC warning #f)
239 pr33902_e() pr33902_e()