lint: add tests that trigger a few more messages
This commit is contained in:
parent
4470ca264c
commit
3029566535
|
@ -1,7 +1,13 @@
|
|||
/* $NetBSD: msg_216.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */
|
||||
/* $NetBSD: msg_216.c,v 1.2 2021/01/30 17:02:58 rillig Exp $ */
|
||||
# 3 "msg_216.c"
|
||||
|
||||
// Test for message: function %s has return (e); and return; [216]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
/* implicit int */
|
||||
random(int n)
|
||||
{
|
||||
if (n < 0)
|
||||
return -3;
|
||||
if (n < 2)
|
||||
return;
|
||||
} /* expect: 216 */
|
||||
|
|
|
@ -1 +1 @@
|
|||
msg_216.c(6): syntax error ':' [249]
|
||||
msg_216.c(13): warning: function random has return (e); and return; [216]
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
/* $NetBSD: msg_217.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */
|
||||
/* $NetBSD: msg_217.c,v 1.2 2021/01/30 17:02:58 rillig Exp $ */
|
||||
# 3 "msg_217.c"
|
||||
|
||||
// Test for message: function %s falls off bottom without returning value [217]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
int
|
||||
random(int n)
|
||||
{
|
||||
if (n < 0)
|
||||
return -3;
|
||||
} /* expect: 217 */
|
||||
|
|
|
@ -1 +1 @@
|
|||
msg_217.c(6): syntax error ':' [249]
|
||||
msg_217.c(11): warning: function random falls off bottom without returning value [217]
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
/* $NetBSD: msg_220.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */
|
||||
/* $NetBSD: msg_220.c,v 1.2 2021/01/30 17:02:58 rillig Exp $ */
|
||||
# 3 "msg_220.c"
|
||||
|
||||
// Test for message: fallthrough on case statement [220]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
/* lint1-extra-flags: -h */
|
||||
|
||||
extern void
|
||||
println(const char *);
|
||||
|
||||
void
|
||||
example(int n)
|
||||
{
|
||||
switch (n) {
|
||||
case 1:
|
||||
case 3:
|
||||
case 5:
|
||||
println("odd");
|
||||
case 2: /* expect: 220 */
|
||||
case 7:
|
||||
println("prime");
|
||||
default: /* expect: 284 */
|
||||
println("number");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
msg_220.c(6): syntax error ':' [249]
|
||||
msg_220.c(19): warning: fallthrough on case statement [220]
|
||||
msg_220.c(22): warning: fallthrough on default statement [284]
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
/* $NetBSD: msg_223.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */
|
||||
/* $NetBSD: msg_223.c,v 1.2 2021/01/30 17:02:58 rillig Exp $ */
|
||||
# 3 "msg_223.c"
|
||||
|
||||
// Test for message: end-of-loop code not reached [223]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void
|
||||
example(int n)
|
||||
{
|
||||
for (int i = 0; i < n; i++) /* expect: 223 */
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
msg_223.c(6): syntax error ':' [249]
|
||||
msg_223.c(9): warning: end-of-loop code not reached [223]
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
/* $NetBSD: msg_224.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */
|
||||
/* $NetBSD: msg_224.c,v 1.2 2021/01/30 17:02:58 rillig Exp $ */
|
||||
# 3 "msg_224.c"
|
||||
|
||||
// Test for message: cannot recover from previous errors [224]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void example1(void) { "syntax" error; } /* expect: 249 */
|
||||
void example2(void) { "syntax" error; } /* expect: 249 */
|
||||
void example3(void) { "syntax" error; } /* expect: 249 */
|
||||
void example4(void) { "syntax" error; } /* expect: 249 */
|
||||
void example5(void) { "syntax" error; } /* expect: 249, 224 */
|
||||
void example6(void) { "syntax" error; }
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
msg_224.c(6): syntax error ':' [249]
|
||||
msg_224.c(6): syntax error 'error' [249]
|
||||
msg_224.c(7): syntax error 'error' [249]
|
||||
msg_224.c(8): syntax error 'error' [249]
|
||||
msg_224.c(9): syntax error 'error' [249]
|
||||
msg_224.c(10): syntax error 'error' [249]
|
||||
msg_224.c(10): cannot recover from previous errors [224]
|
||||
|
|
Loading…
Reference in New Issue