From cd6f591d1111a6f746e0a5f5f342efeb8b776220 Mon Sep 17 00:00:00 2001 From: cuz Date: Mon, 4 Dec 2000 20:39:17 +0000 Subject: [PATCH] Minor rearrangements to make the code more robust in case of errors. git-svn-id: svn://svn.cc65.org/cc65/trunk@549 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/compile.c | 2 +- src/cc65/symtab.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc65/compile.c b/src/cc65/compile.c index b4784fcc6..a532881ce 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -219,7 +219,7 @@ static void Parse (void) } /* Function declaration? */ - if (IsTypeFunc (Decl.Type)) { + if (Entry && IsTypeFunc (Entry->Type)) { /* Function */ if (!comma) { diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index 8dcd432ae..3bab90d7c 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -609,7 +609,7 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags) if ((Entry->Flags & SC_DEF) != 0 && (Flags & SC_DEF) != 0) { /* Trying to define the label more than once */ Error ("Label `%s' is defined more than once", Name); - } + } Entry->Flags |= Flags; } else { @@ -696,6 +696,7 @@ SymEntry* AddGlobalSym (const char* Name, type* Type, unsigned Flags) TypeCmp (Type+DECODE_SIZE+1, EType+DECODE_SIZE+1) < TC_EQUAL) { /* Types not identical: Conflicting types */ Error ("Conflicting types for `%s'", Name); + return Entry; } else { /* Check if we have a size in the existing definition */ if (ESize == 0) { @@ -708,14 +709,15 @@ SymEntry* AddGlobalSym (const char* Name, type* Type, unsigned Flags) /* New type must be identical */ if (TypeCmp (EType, Type) < TC_EQUAL) { Error ("Conflicting types for `%s'", Name); - } + return Entry; + } /* In case of a function, use the new type descriptor, since it * contains pointers to the new symbol tables that are needed if * an actual function definition follows. */ if (IsTypeFunc (Type)) { - CopyEncode (Type+1, EType+1); + CopyEncode (Type+1, EType+1); } } -- 2.39.5