1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-19 06:31:31 +00:00

return-type - new warning suppression type added

This commit is contained in:
Rocky 2021-01-01 15:39:23 +01:00 committed by Oliver Schmidt
parent d90cd11212
commit a9b71b6207
3 changed files with 5 additions and 2 deletions

View File

@ -74,6 +74,7 @@ IntStack WarnUnknownPragma = INTSTACK(1); /* - unknown #pragmas */
IntStack WarnUnusedLabel = INTSTACK(1); /* - unused labels */
IntStack WarnUnusedParam = INTSTACK(1); /* - unused parameters */
IntStack WarnUnusedVar = INTSTACK(1); /* - unused variables */
IntStack WarnReturnType = INTSTACK(1); /* - control reaches end of non-void function */
/* Map the name of a warning to the intstack that holds its state */
typedef struct WarnMapEntry WarnMapEntry;
@ -92,6 +93,7 @@ static WarnMapEntry WarnMap[] = {
{ &WarnUnusedLabel, "unused-label" },
{ &WarnUnusedParam, "unused-param" },
{ &WarnUnusedVar, "unused-var" },
{ &WarnReturnType, "return-type" },
};
Collection DiagnosticStrBufs;

View File

@ -71,6 +71,7 @@ extern IntStack WarnUnknownPragma; /* - unknown #pragmas */
extern IntStack WarnUnusedLabel; /* - unused labels */
extern IntStack WarnUnusedParam; /* - unused parameters */
extern IntStack WarnUnusedVar; /* - unused variables */
extern IntStack WarnReturnType; /* - control reaches end of non-void function */
/* Forward */
struct StrBuf;

View File

@ -654,8 +654,8 @@ void NewFunc (SymEntry* Func, FuncDesc* D)
** environment returning int, output a warning if we didn't see a return
** statement.
*/
if (!F_HasVoidReturn (CurrentFunc) && !F_HasReturn (CurrentFunc) && !C99MainFunc) {
Warning ("Control reaches end of non-void function");
if (!F_HasVoidReturn (CurrentFunc) && !F_HasReturn (CurrentFunc) && !C99MainFunc && IS_Get (&WarnReturnType)) {
Warning ("Control reaches end of non-void function [-Wreturn-type]");
}
/* If this is the main function in a C99 environment returning an int, let