]> git.sur5r.net Git - cc65/commitdiff
Fixed a bug: .ENDPROC without .PROC would crash the assembler
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 17 Mar 2003 10:14:43 +0000 (10:14 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 17 Mar 2003 10:14:43 +0000 (10:14 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@2027 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ca65/error.c
src/ca65/error.h
src/ca65/pseudo.c
src/ca65/symtab.c
src/ca65/symtab.h

index f8f0eabfa953e43a6e51262a0784aa17ad9f074c..f480fe961760c2b856247ec4abda5a7f079a5953 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2002 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* (C) 1998-2003 Ullrich von Bassewitz                                       */
+/*               Römerstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -183,6 +183,7 @@ void ErrorMsg (const FilePos* Pos, unsigned ErrNum, va_list ap)
        "Duplicate `.ELSE'",
                "Conditional assembly branch was never closed",
        "Lexical level was not terminated correctly",
+        "No open lexical level",
        "Segment attribute mismatch",
         "Segment stack overflow",
         "Segment stack is empty",
@@ -190,7 +191,7 @@ void ErrorMsg (const FilePos* Pos, unsigned ErrNum, va_list ap)
        "CPU not supported",
        "Counter underflow",
        "Undefined label",
-       "Open `%s´",
+               "Open `%s'",
        "File name `%s' not found in file table",
     };
 
index c6c9a772d2ef1b9a573b7d011a940c3c0e101887..c13cd6875bbca2a89774b92baf2b0f83c3e41061 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2002 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* (C) 1998-2003 Ullrich von Bassewitz                                       */
+/*               Römerstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -124,6 +124,7 @@ enum Errors {
     ERR_DUPLICATE_ELSE,
     ERR_OPEN_IF,
     ERR_OPEN_PROC,
+    ERR_NO_OPEN_PROC,
     ERR_SEG_ATTR_MISMATCH,
     ERR_SEGSTACK_OVERFLOW,
     ERR_SEGSTACK_EMPTY,
index 01bd9a100307071400523ec5f1f3c8f13aebb6a3..0c168a1d9cf59938ae9fdcf54393ceb9190aa3b5 100644 (file)
@@ -605,8 +605,13 @@ static void DoEnd (void)
 
 static void DoEndProc (void)
 /* Leave a lexical level */
-{
-    SymLeaveLevel ();
+{           
+    if (!SymIsLocalLevel ()) {
+        /* No local symbol table level open */
+        ErrorSkip (ERR_NO_OPEN_PROC);
+    } else {
+        SymLeaveLevel ();
+    }
 }
 
 
index c4c37135f717659e1fcd674f8014187a00b07935..d5087ebf9c0dd6d4c34dcbd73b56789d500b397b 100644 (file)
@@ -379,12 +379,20 @@ void SymEnterLevel (void)
 
 void SymLeaveLevel (void)
 /* Leave the current lexical level */
-{
+{                          
     SymTab = SymTab->BackLink;
 }
 
 
 
+int SymIsLocalLevel (void)
+/* Return true if we ae on a local symbol table level. */
+{
+    return (SymTab != RootTab);
+}
+
+
+
 void SymDef (const char* Name, ExprNode* Expr, int ZP, int Label)
 /* Define a new symbol */
 {
index 54ee0620350ec44d6e4c20224d7394c19297158e..4492889b5bc4af5043351d63b696f6899500a52b 100644 (file)
@@ -73,6 +73,9 @@ void SymEnterLevel (void);
 void SymLeaveLevel (void);
 /* Leave the current lexical level */
 
+int SymIsLocalLevel (void);
+/* Return true if we ae on a local symbol table level. */
+
 void SymDef (const char* Name, ExprNode* Expr, int ZP, int Label);
 /* Define a new symbol */
 
@@ -104,7 +107,7 @@ void SymGlobal (const char* Name);
 /* Mark the given symbol as a global symbol, that is, as a symbol that is
  * either imported or exported.
  */
-                                
+
 void SymGlobalZP (const char* Name);
 /* Mark the given symbol as a global zeropage symbol, that is, as a symbol
  * that is either imported or exported.