#include <stdlib.h>
-#include "../common/version.h"
+/* common */
+#include "version.h"
+/* cc65 */
#include "asmlabel.h"
#include "codegen.h"
#include "declare.h"
/* 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;
}
/* Get the symbol flags */
SymFlags = Spec.StorageClass;
- if (IsFunc (Decl.Type)) {
+ if (IsTypeFunc (Decl.Type)) {
SymFlags |= SC_FUNC;
} else {
if (NeedStorage) {
* 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);
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 */
}
/* Function declaration? */
- if (IsFunc (Decl.Type)) {
+ if (Entry && IsTypeFunc (Entry->Type)) {
/* Function */
if (!comma) {