From fa1f814be54ded43ac6aefc9ffe76d294fbe6b87 Mon Sep 17 00:00:00 2001 From: cuz Date: Fri, 21 Sep 2001 13:48:55 +0000 Subject: [PATCH] Fixed a bug git-svn-id: svn://svn.cc65.org/cc65/trunk@960 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/locals.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/cc65/locals.c b/src/cc65/locals.c index 4ac8f357a..fccc8040e 100644 --- a/src/cc65/locals.c +++ b/src/cc65/locals.c @@ -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; -- 2.39.5