Skip to content

Commit eb1b47c

Browse files
committed
Test top-level function effect. Thanks, Balázs for this example
1 parent c725ed7 commit eb1b47c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

clang/test/Analysis/void-call-exit-modelling.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,12 @@ void inf_loop_break_callee() {
1515
void inf_loop_break_caller() {
1616
inf_loop_break_callee(); // expected-note{{Calling 'inf_loop_break_callee'}}
1717
}
18+
19+
void inf_loop_break_top() {
20+
void* data = malloc(10); // expected-note{{Memory is allocated}}
21+
while (1) { // expected-note{{Loop condition is true}}
22+
(void)data;
23+
break; // No note that we jump to the line above from this break
24+
} // expected-note@-1{{Execution jumps to the end of the function}}
25+
} // expected-warning{{Potential leak of memory pointed to by 'data'}}
26+
// expected-note@-1 {{Potential leak of memory pointed to by 'data'}}

0 commit comments

Comments
 (0)