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

Merge pull request #2271 from acqn/InternalFix

[cc65] Fixed assertion failure when there is an undeclared symbol used in a parameter list
This commit is contained in:
Bob Andrews 2023-11-28 15:03:09 +01:00 committed by GitHub
commit 2af16ee82b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -1902,6 +1902,7 @@ static FuncDesc* ParseFuncDecl (void)
}
/* Parse params */
PushLexicalLevel (LEX_LEVEL_PARAM_LIST);
if ((F->Flags & FD_OLDSTYLE) == 0) {
/* New-style function */
ParseAnsiParamList (F);
@ -1909,6 +1910,7 @@ static FuncDesc* ParseFuncDecl (void)
/* Old-style function */
ParseOldStyleParamList (F);
}
PopLexicalLevel ();
/* Remember the last function parameter. We need it later for several
** purposes, for example when passing stuff to fastcall functions. Since

View File

@ -1221,7 +1221,14 @@ SymEntry* AddLocalSym (const char* Name, const Type* T, unsigned Flags, int Offs
ident Ident;
/* Do we have an entry with this name already? */
SymEntry* Entry = FindSymInTable (Tab, Name, HashStr (Name));
SymEntry* Entry;
/* HACK: only allows to add parameter symbols in a parameter list */
if ((Flags & SC_PARAM) == 0 && GetLexicalLevel () == LEX_LEVEL_PARAM_LIST) {
return 0;
}
Entry = FindSymInTable (Tab, Name, HashStr (Name));
if (Entry) {
int CheckExtern = 0;
@ -1419,7 +1426,9 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags)
/* Add an alias of the global symbol to the local symbol table */
if (Tab == SymTab0 && SymTab != SymTab0 && Entry->Owner != SymTab && Alias == 0) {
Alias = AddLocalSym (Name, T, SC_ALIAS, 0);
Alias->V.A.Field = Entry;
if (Alias != 0) {
Alias->V.A.Field = Entry;
}
}
/* Return the entry */

View File

@ -78,6 +78,7 @@ struct LexicalLevel {
#define LEX_LEVEL_FUNCTION 2U
#define LEX_LEVEL_BLOCK 3U
#define LEX_LEVEL_STRUCT 4U
#define LEX_LEVEL_PARAM_LIST 5U /* HACK for error recovery */
/* Forwards */
struct FuncDesc;