lint: add tests that trigger a few more messages

This commit is contained in:
rillig 2021-01-30 17:02:58 +00:00
parent 4470ca264c
commit 3029566535
10 changed files with 62 additions and 20 deletions

View File

@ -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 */

View File

@ -1 +1 @@
msg_216.c(6): syntax error ':' [249]
msg_216.c(13): warning: function random has return (e); and return; [216]

View File

@ -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 */

View File

@ -1 +1 @@
msg_217.c(6): syntax error ':' [249]
msg_217.c(11): warning: function random falls off bottom without returning value [217]

View File

@ -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");
}
}

View File

@ -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]

View File

@ -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;
}

View File

@ -1 +1 @@
msg_223.c(6): syntax error ':' [249]
msg_223.c(9): warning: end-of-loop code not reached [223]

View File

@ -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; }

View File

@ -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]