In an old style function definition, print a diagnostic if a type is assigned
twice to a parameter. git-svn-id: svn://svn.cc65.org/cc65/trunk@3861 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -6,8 +6,8 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2005 Ullrich von Bassewitz */
|
/* (C) 1998-2008 Ullrich von Bassewitz */
|
||||||
/* R<EFBFBD>merstra<EFBFBD>e 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
@@ -696,7 +696,7 @@ static void ParseOldStyleParamList (FuncDesc* F)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create a symbol table entry with type int */
|
/* Create a symbol table entry with type int */
|
||||||
AddLocalSym (CurTok.Ident, type_int, SC_AUTO | SC_PARAM | SC_DEF, 0);
|
AddLocalSym (CurTok.Ident, type_int, SC_AUTO | SC_PARAM | SC_DEF | SC_DEFTYPE, 0);
|
||||||
|
|
||||||
/* Count arguments */
|
/* Count arguments */
|
||||||
++F->ParamCount;
|
++F->ParamCount;
|
||||||
@@ -745,8 +745,18 @@ static void ParseOldStyleParamList (FuncDesc* F)
|
|||||||
/* We have a name given. Search for the symbol */
|
/* We have a name given. Search for the symbol */
|
||||||
SymEntry* Sym = FindLocalSym (Decl.Ident);
|
SymEntry* Sym = FindLocalSym (Decl.Ident);
|
||||||
if (Sym) {
|
if (Sym) {
|
||||||
|
/* Check if we already changed the type for this
|
||||||
|
* parameter
|
||||||
|
*/
|
||||||
|
if (Sym->Flags & SC_DEFTYPE) {
|
||||||
/* Found it, change the default type to the one given */
|
/* Found it, change the default type to the one given */
|
||||||
ChangeSymType (Sym, ParamTypeCvt (Decl.Type));
|
ChangeSymType (Sym, ParamTypeCvt (Decl.Type));
|
||||||
|
/* Reset the "default type" flag */
|
||||||
|
Sym->Flags &= ~SC_DEFTYPE;
|
||||||
|
} else {
|
||||||
|
/* Type has already been changed */
|
||||||
|
Error ("Redefinition for parameter `%s'", Sym->Name);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Error ("Unknown identifier: `%s'", Decl.Ident);
|
Error ("Unknown identifier: `%s'", Decl.Ident);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000-2006 Ullrich von Bassewitz */
|
/* (C) 2000-2008 Ullrich von Bassewitz */
|
||||||
/* R<EFBFBD>merstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
@@ -76,6 +76,7 @@ struct Segments;
|
|||||||
#define SC_PARAM 0x0080U /* This is a function parameter */
|
#define SC_PARAM 0x0080U /* This is a function parameter */
|
||||||
#define SC_FUNC 0x0100U /* Function entry */
|
#define SC_FUNC 0x0100U /* Function entry */
|
||||||
|
|
||||||
|
#define SC_DEFTYPE 0x0200U /* Parameter has default type (=int, old style) */
|
||||||
#define SC_STORAGE 0x0400U /* Symbol with associated storage */
|
#define SC_STORAGE 0x0400U /* Symbol with associated storage */
|
||||||
#define SC_DEFAULT 0x0800U /* Flag: default storage class was used */
|
#define SC_DEFAULT 0x0800U /* Flag: default storage class was used */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user