]> git.sur5r.net Git - cc65/blobdiff - src/cc65/compile.c
Moved verbose output to a shared module in the common/ directory.
[cc65] / src / cc65 / compile.c
index 1177c51e96363d5cc5144ad03feb53fc3661fcac..a532881cec6d5bd39053693126188538b0245275 100644 (file)
 
 #include <stdlib.h>
 
-#include "../common/version.h"
+/* common */
+#include "version.h"
 
+/* cc65 */
 #include "asmlabel.h"
 #include "codegen.h"
 #include "declare.h"
@@ -97,7 +99,7 @@ static void Parse (void)
 
        /* Don't accept illegal storage classes */
        if (Spec.StorageClass == SC_AUTO || Spec.StorageClass == SC_REGISTER) {
-           Error (ERR_ILLEGAL_STORAGE_CLASS);
+           Error ("Illegal storage class");
            Spec.StorageClass = SC_EXTERN | SC_STATIC;
        }
 
@@ -134,7 +136,7 @@ static void Parse (void)
 
            /* Get the symbol flags */
            SymFlags = Spec.StorageClass;
-           if (IsFunc (Decl.Type)) {
+           if (IsTypeFunc (Decl.Type)) {
                SymFlags |= SC_FUNC;
            } else {
                if (NeedStorage) {
@@ -159,19 +161,23 @@ static void Parse (void)
                     * void types in non ANSI mode.
                     */
                            if (Size == 0) {
-                       if (!IsVoid (Decl.Type)) {
-                           if (!IsArray (Decl.Type)) {
-                               /* Size is unknown and not an array */
-                               Error (ERR_UNKNOWN_SIZE);
-                           }
-                       } else if (ANSI) {
-                           /* We cannot declare variables of type void */
-                           Error (ERR_ILLEGAL_TYPE);
-                       }
+                       if (!IsTypeVoid (Decl.Type)) {
+                           if (!IsTypeArray (Decl.Type)) {
+                               /* Size is unknown and not an array */
+                               Error ("Variable `%s' has unknown size", Decl.Ident);
+                           }
+                       } else if (ANSI) {
+                           /* We cannot declare variables of type void */
+                           Error ("Illegal type for variable `%s'", Decl.Ident);
+                       }
                    }
 
-                   /* Switch to the data segment */
-                   g_usedata ();
+                   /* Switch to the data or rodata segment */
+                   if (IsQualConst (Decl.Type)) {
+                       g_userodata ();
+                   } else {
+                       g_usedata ();
+                   }
 
                    /* Define a label */
                    g_defgloblabel (Entry->Name);
@@ -183,12 +189,12 @@ static void Parse (void)
                    ParseInit (Entry->Type);
                } else {
 
-                   if (IsVoid (Decl.Type)) {
+                   if (IsTypeVoid (Decl.Type)) {
                        /* We cannot declare variables of type void */
-                       Error (ERR_ILLEGAL_TYPE);
+                       Error ("Illegal type for variable `%s'", Decl.Ident);
                    } else if (Size == 0) {
                        /* Size is unknown */
-                       Error (ERR_UNKNOWN_SIZE);
+                       Error ("Variable `%s' has unknown size", Decl.Ident);
                    }
 
                    /* Switch to the BSS segment */
@@ -213,7 +219,7 @@ static void Parse (void)
        }
 
        /* Function declaration? */
-       if (IsFunc (Decl.Type)) {
+       if (Entry && IsTypeFunc (Entry->Type)) {
 
            /* Function */
            if (!comma) {