]> git.sur5r.net Git - cc65/blobdiff - src/cc65/locals.c
Fixed two compiler warnings.
[cc65] / src / cc65 / locals.c
index 61ec01a3d9a2363b9c3864cc2b87738e7e6558f8..710d05e33a34a7442bbaee93f432246fd2c08378 100644 (file)
@@ -324,6 +324,12 @@ static unsigned ParseAutoDecl (Declaration* Decl, unsigned* SC)
 
             /* Mark the variable as referenced */
             *SC |= SC_REF;
+
+        } else {
+
+            /* No assignment - allocate a label and space for the variable */
+            SymData = AllocStorage (g_usebss, Size);
+
         }
     }
 
@@ -349,8 +355,12 @@ static unsigned ParseStaticDecl (Declaration* Decl, unsigned* SC)
     /* Static data */
     if (CurTok.Tok == TOK_ASSIGN) {
 
-        /* Initialization ahead, switch to data segment and define a label */
-        if (IsQualConst (Decl->Type)) {
+        /* Initialization ahead, switch to data segment and define a label.
+         * For arrays, we need to check the elements of the array for 
+         * constness, not the array itself.
+         */
+        if (IsQualConst (Decl->Type) ||
+            (IsTypeArray (Decl->Type) && IsQualConst (GetElementType (Decl->Type)))) {
             SymData = AllocLabel (g_userodata);
         } else {
             SymData = AllocLabel (g_usedata);