Do not output a warning about a missing "return" in a function if the function
exit is unreachable.
This commit is contained in:
@@ -433,7 +433,7 @@ void UnreachableCodeWarning (void)
|
||||
*/
|
||||
if (CurTok.LI && NextTok.LI) {
|
||||
if (CurTok.Tok == TOK_LCURLY) {
|
||||
/* Do not point to the compoung statement but to the first
|
||||
/* Do not point to the compound statement but to the first
|
||||
** statement within it. If the compound statement is empty
|
||||
** do not even output a warning. This fails of course for
|
||||
** nested compounds but will do the right thing in most cases.
|
||||
|
||||
@@ -453,6 +453,7 @@ void NewFunc (SymEntry* Func, FuncDesc* D)
|
||||
SymEntry* Param;
|
||||
const Type* RType; /* Real type used for struct parameters */
|
||||
const Type* ReturnType; /* Return type */
|
||||
int StmtFlags; /* Flow control flags for the function compound */
|
||||
|
||||
/* Remember this function descriptor used for definition */
|
||||
GetFuncDesc (Func->Type)->FuncDef = D;
|
||||
@@ -627,10 +628,12 @@ void NewFunc (SymEntry* Func, FuncDesc* D)
|
||||
CurrentFunc->TopLevelSP = StackPtr;
|
||||
|
||||
/* Now process statements in this block checking for unreachable code */
|
||||
StatementBlock (0);
|
||||
StmtFlags = StatementBlock (0);
|
||||
|
||||
/* Check if this function is missing a return value */
|
||||
if (!F_HasVoidReturn (CurrentFunc) && !F_HasReturn (CurrentFunc)) {
|
||||
if (!SF_Unreach (StmtFlags) &&
|
||||
!F_HasVoidReturn (CurrentFunc) &&
|
||||
!F_HasReturn (CurrentFunc)) {
|
||||
/* If this is the main function in a C99 environment returning an int,
|
||||
** let it always return zero. Otherwise output a warning.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user