lint: fix reachability for if-then-else statements
This commit is contained in:
parent
f23731fc8b
commit
352b5b3b4b
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: msg_130.c,v 1.11 2021/03/10 00:02:00 rillig Exp $ */
|
||||
/* $NetBSD: msg_130.c,v 1.12 2021/03/21 15:24:56 rillig Exp $ */
|
||||
# 3 "msg_130.c"
|
||||
|
||||
// Test for message: enum type mismatch: '%s' '%s' '%s' [130]
|
||||
|
@ -89,7 +89,7 @@ enum_constant_from_unnamed_type(int x)
|
|||
if (sizeof_int == sizeof_uint) /* expect: 130 *//* FIXME */
|
||||
return 6;
|
||||
|
||||
return 0;
|
||||
return 0; /* expect: statement not reached */
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -2,4 +2,5 @@ msg_130.c(29): warning: enum type mismatch: 'enum color' ':' 'enum daytime' [130
|
|||
msg_130.c(31): warning: enum type mismatch: 'enum color' '!=' 'enum size' [130]
|
||||
msg_130.c(32): warning: enum type mismatch: 'enum color' '==' 'enum size' [130]
|
||||
msg_130.c(89): warning: enum type mismatch: 'enum <unnamed>' '==' 'enum <unnamed>' [130]
|
||||
msg_130.c(92): warning: statement not reached [193]
|
||||
msg_130.c(127): warning: enum type mismatch: 'enum <unnamed>' '==' 'enum <unnamed>' [130]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: msg_193.c,v 1.4 2021/03/21 14:36:59 rillig Exp $ */
|
||||
/* $NetBSD: msg_193.c,v 1.5 2021/03/21 15:24:56 rillig Exp $ */
|
||||
# 3 "msg_193.c"
|
||||
|
||||
// Test for message: statement not reached [193]
|
||||
|
@ -140,7 +140,7 @@ test_if_return(void)
|
|||
{
|
||||
if (1)
|
||||
return;
|
||||
unreachable(); /* TODO: expect: 193 */
|
||||
unreachable(); /* expect: 193 */
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -10,6 +10,7 @@ msg_193.c(124): warning: statement not reached [193]
|
|||
msg_193.c(128): warning: statement not reached [193]
|
||||
msg_193.c(131): warning: statement not reached [193]
|
||||
msg_193.c(133): warning: statement not reached [193]
|
||||
msg_193.c(143): warning: statement not reached [193]
|
||||
msg_193.c(152): warning: statement not reached [193]
|
||||
msg_193.c(161): warning: statement not reached [193]
|
||||
msg_193.c(169): warning: statement not reached [193]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: msg_217.c,v 1.8 2021/03/21 14:36:59 rillig Exp $ */
|
||||
/* $NetBSD: msg_217.c,v 1.9 2021/03/21 15:24:56 rillig Exp $ */
|
||||
# 3 "msg_217.c"
|
||||
|
||||
// Test for message: function %s falls off bottom without returning value [217]
|
||||
|
@ -55,7 +55,7 @@ reachable_continue_leads_to_endless_loop(void)
|
|||
continue;
|
||||
break;
|
||||
}
|
||||
} /* FIXME *//* expect: 217 */
|
||||
}
|
||||
|
||||
int
|
||||
unreachable_continue_falls_through(void)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
msg_217.c(11): warning: function random falls off bottom without returning value [217]
|
||||
msg_217.c(58): warning: function reachable_continue_leads_to_endless_loop falls off bottom without returning value [217]
|
||||
msg_217.c(65): warning: statement not reached [193]
|
||||
msg_217.c(68): warning: function unreachable_continue_falls_through falls off bottom without returning value [217]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: func.c,v 1.89 2021/03/21 14:49:21 rillig Exp $ */
|
||||
/* $NetBSD: func.c,v 1.90 2021/03/21 15:24:55 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: func.c,v 1.89 2021/03/21 14:49:21 rillig Exp $");
|
||||
__RCSID("$NetBSD: func.c,v 1.90 2021/03/21 15:24:55 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -631,12 +631,13 @@ if2(void)
|
|||
void
|
||||
if3(bool els)
|
||||
{
|
||||
|
||||
if (els) {
|
||||
reached |= cstmt->c_reached_end_of_then;
|
||||
} else {
|
||||
if (cstmt->c_reached_end_of_then)
|
||||
reached = true;
|
||||
}
|
||||
else if (cstmt->c_always_then)
|
||||
reached = false;
|
||||
else if (!els)
|
||||
reached = true;
|
||||
|
||||
popctrl(T_IF);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue