mirror of
https://github.com/cc65/cc65.git
synced 2024-12-25 02:29:52 +00:00
Warn when structs are passed by value to a function.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4369 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
1f489fd9e1
commit
1f92d6bfa2
@ -1167,6 +1167,13 @@ static void ParseAnsiParamList (FuncDesc* F)
|
||||
/* Create a symbol table entry */
|
||||
AddLocalSym (Decl.Ident, ParamTypeCvt (Decl.Type), Decl.StorageClass, 0);
|
||||
|
||||
/* If the parameter is a struct or union, emit a warning */
|
||||
if (IsClassStruct (Decl.Type)) {
|
||||
if (IS_Get (&WarnStructParam)) {
|
||||
Warning ("Passing struct by value for parameter `%s'", Decl.Ident);
|
||||
}
|
||||
}
|
||||
|
||||
/* Count arguments */
|
||||
++F->ParamCount;
|
||||
|
||||
|
@ -63,6 +63,7 @@ unsigned WarningCount = 0;
|
||||
/* Warning and error options */
|
||||
IntStack WarnEnable = INTSTACK(1); /* Enable warnings */
|
||||
IntStack WarningsAreErrors = INTSTACK(0); /* Treat warnings as errors */
|
||||
IntStack WarnStructParam = INTSTACK(1); /* Warn about structs passed by val */
|
||||
IntStack WarnUnusedLabel = INTSTACK(1); /* Warn about unused labels */
|
||||
IntStack WarnUnusedParam = INTSTACK(1); /* Warn about unused parameters */
|
||||
IntStack WarnUnusedVar = INTSTACK(1); /* Warn about unused variables */
|
||||
@ -77,6 +78,7 @@ struct WarnMapEntry {
|
||||
static WarnMapEntry WarnMap[] = {
|
||||
/* Keep sorted, even if this isn't used for now */
|
||||
{ &WarningsAreErrors, "error" },
|
||||
{ &WarnStructParam, "struct-param" },
|
||||
{ &WarnUnknownPragma, "unknown-pragma" },
|
||||
{ &WarnUnusedLabel, "unused-label" },
|
||||
{ &WarnUnusedParam, "unused-param" },
|
||||
|
@ -60,6 +60,7 @@ extern unsigned WarningCount;
|
||||
/* Warning and error options */
|
||||
extern IntStack WarnEnable; /* Enable warnings */
|
||||
extern IntStack WarningsAreErrors; /* Treat warnings as errors */
|
||||
extern IntStack WarnStructParam; /* Warn about structs passed by val */
|
||||
extern IntStack WarnUnusedLabel; /* Warn about unused labels */
|
||||
extern IntStack WarnUnusedParam; /* Warn about unused parameters */
|
||||
extern IntStack WarnUnusedVar; /* Warn about unused variables */
|
||||
|
Loading…
Reference in New Issue
Block a user