]> git.sur5r.net Git - cc65/commitdiff
Fixed a bug
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 21 Sep 2001 13:48:55 +0000 (13:48 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 21 Sep 2001 13:48:55 +0000 (13:48 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@960 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/cc65/locals.c

index 4ac8f357a1ad4e4a2ead340df07b068806279d3c..fccc8040e94429ffd5f36384ce1efbcba9f7b146 100644 (file)
@@ -240,20 +240,23 @@ static void ParseOneDecl (const DeclSpec* Spec)
                    /* Skip the '=' */
                    NextToken ();
 
-                   /* Get the expression into the primary */
-                   expression1 (&lval);
-
-                   /* Make type adjustments if needed */
-                   assignadjust (Decl.Type, &lval);
-
                    /* Setup the type flags for the assignment */
-                   flags = TypeOf (Decl.Type);
-                   if (Size == 1) {
-                       flags |= CF_FORCECHAR;
+                   flags = Size == 1? CF_FORCECHAR : CF_NONE;
+
+                   /* Get the expression into the primary */
+                   if (evalexpr (flags, hie1, &lval) == 0) {
+                       /* Constant expression. Adjust the types */
+                       assignadjust (Decl.Type, &lval);
+                       flags |= CF_CONST;
+                       /* Load it into the primary */
+                       exprhs (flags, 0, &lval);
+                   } else {
+                       /* Expression is not constant and in the primary */
+                       assignadjust (Decl.Type, &lval);
                    }
 
                    /* Store the value into the variable */
-                   g_putstatic (flags, SymData, 0);
+                   g_putstatic (flags | TypeOf (Decl.Type), SymData, 0);
 
                    /* Mark the variable as referenced */
                    SC |= SC_REF;