]> git.sur5r.net Git - cc65/blobdiff - src/ld65/cfgexpr.c
Merge remote-tracking branch 'upstream/master' into a5200
[cc65] / src / ld65 / cfgexpr.c
index 584ad0d4ae35f8734221db145ecea6a46e056ad2..d922f49ba3fae8f28e494e0ba53525893869b771 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2005-2010, Ullrich von Bassewitz                                      */
+/* (C) 2005-2011, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
 #include "error.h"
 #include "exports.h"
 #include "expr.h"
+#include "lineinfo.h"
 #include "scanner.h"
 #include "spool.h"
 
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
@@ -63,7 +64,7 @@ static ExprNode* Factor (void)
 
     switch (CfgTok) {
 
-       case CFGTOK_IDENT:
+        case CFGTOK_IDENT:
             /* Get the name as an id */
             Name = GetStrBufId (&CfgSVal);
 
@@ -74,17 +75,18 @@ static ExprNode* Factor (void)
             } else {
                 N = NewExprNode (0, EXPR_SYMBOL);
                 N->V.Imp = InsertImport (GenImport (Name, ADDR_SIZE_ABS));
+                CollAppend (&N->V.Imp->RefLines, GenLineInfo (&CfgErrorPos));
             }
 
             /* Skip the symbol name */
             CfgNextTok ();
             break;
 
-       case CFGTOK_INTCON:
+        case CFGTOK_INTCON:
             /* An integer constant */
             N = LiteralExpr (CfgIVal, 0);
-           CfgNextTok ();
-                   break;
+            CfgNextTok ();
+            break;
 
         case CFGTOK_PLUS:
             /* Unary plus */
@@ -99,16 +101,16 @@ static ExprNode* Factor (void)
             N->Left = Factor ();
             break;
 
-               case CFGTOK_LPAR:
+        case CFGTOK_LPAR:
             /* Left parenthesis */
-                   CfgNextTok ();
-                   N = CfgExpr ();
-                   CfgConsume (CFGTOK_RPAR, "')' expected");
-                   break;
-
-               default:
-                   CfgError ("Invalid expression: %d", CfgTok);
-                   break;
+            CfgNextTok ();
+            N = CfgExpr ();
+            CfgConsume (CFGTOK_RPAR, "')' expected");
+            break;
+
+        default:
+            CfgError (&CfgErrorPos, "Invalid expression: %d", CfgTok);
+            break;
     }
 
     /* Return the new expression node */
@@ -211,7 +213,7 @@ long CfgConstExpr (void)
 
     /* Check that it's const */
     if (!IsConstExpr (Expr)) {
-        CfgError ("Constant expression expected");
+        CfgError (&CfgErrorPos, "Constant expression expected");
     }
 
     /* Get the value */
@@ -236,12 +238,9 @@ long CfgCheckedConstExpr (long Min, long Max)
 
     /* Check the range */
     if (Val < Min || Val > Max) {
-       CfgError ("Range error");
+        CfgError (&CfgErrorPos, "Range error");
     }
 
     /* Return the value */
     return Val;
 }
-
-
-