]> git.sur5r.net Git - cc65/blobdiff - src/cc65/symentry.h
In an old style function definition, print a diagnostic if a type is assigned
[cc65] / src / cc65 / symentry.h
index 299b0b08efedd1ed7d984842eaba3675ff34bb28..a43356cc9e0ac73af5a6a532114b8f6d0903ef42 100644 (file)
@@ -6,9 +6,9 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2002 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
+/* (C) 2000-2008 Ullrich von Bassewitz                                       */
+/*               Roemerstrasse 52                                            */
+/*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
@@ -40,6 +40,9 @@
 
 #include <stdio.h>
 
+/* common */
+#include "inline.h"
+
 /* cc65 */
 #include "datatype.h"
 
@@ -73,6 +76,7 @@ struct Segments;
 #define SC_PARAM               0x0080U /* This is a function parameter */
 #define SC_FUNC                0x0100U /* Function entry */
 
+#define SC_DEFTYPE      0x0200U /* Parameter has default type (=int, old style) */
 #define SC_STORAGE             0x0400U /* Symbol with associated storage */
 #define SC_DEFAULT             0x0800U /* Flag: default storage class was used */
 
@@ -81,7 +85,7 @@ struct Segments;
 
 #define SC_TYPE                0x4000U /* This is a type, struct, typedef, etc. */
 #define SC_STRUCT              0x4001U /* Struct or union */
-#define SC_SFLD                0x4002U /* Struct or union field */
+#define SC_STRUCTFIELD  0x4002U        /* Struct or union field */
 #define SC_TYPEDEF             0x4003U /* A typedef */
 
 #define SC_ZEROPAGE    0x8000U /* Symbol marked as zeropage */
@@ -97,19 +101,27 @@ struct SymEntry {
     SymEntry*                          Link;     /* General purpose single linked list */
     struct SymTable*           Owner;    /* Symbol table the symbol is in */
     unsigned                           Flags;    /* Symbol flags */
-    type*                              Type;     /* Symbol type */
+    Type*                              Type;     /* Symbol type */
     char*                       AsmName;  /* Assembler name if any */
 
     /* Data that differs for the different symbol types */
     union {
 
-       /* Offset for locals or struct members */
-       int                     Offs;
+               /* Offset for locals or struct members */
+               int                     Offs;
+
+               /* Label name for static symbols */
+               unsigned                Label;
 
-       /* Label name for static symbols */
-       unsigned                Label;
+        /* Register bank offset and offset of the saved copy on stack for
+         * register variables.
+         */
+        struct {
+            int                 RegOffs;
+            int                 SaveOffs;
+        } R;
 
-       /* Value for constants (including enums) */
+               /* Value for constants (including enums) */
                long                    ConstVal;
 
        /* Data for structs/unions */
@@ -145,10 +157,61 @@ void FreeSymEntry (SymEntry* E);
 void DumpSymEntry (FILE* F, const SymEntry* E);
 /* Dump the given symbol table entry to the file in readable form */
 
-int IsTypeDef (const SymEntry* E);
+#if defined(HAVE_INLINE)
+INLINE int SymIsTypeDef (const SymEntry* Sym)
 /* Return true if the given entry is a typedef entry */
+{
+    return ((Sym->Flags & SC_TYPEDEF) == SC_TYPEDEF);
+}
+#else
+#  define SymIsTypeDef(Sym)     (((Sym)->Flags & SC_TYPEDEF) == SC_TYPEDEF)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE int SymIsDef (const SymEntry* Sym)
+/* Return true if the given entry is defined */
+{
+    return ((Sym->Flags & SC_DEF) == SC_DEF);
+}
+#else
+#  define SymIsDef(Sym)     (((Sym)->Flags & SC_DEF) == SC_DEF)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE int SymIsRef (const SymEntry* Sym)
+/* Return true if the given entry is referenced */
+{
+    return ((Sym->Flags & SC_REF) == SC_REF);
+}
+#else
+#  define SymIsRef(Sym)     (((Sym)->Flags & SC_REF) == SC_REF)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE int SymIsRegVar (const SymEntry* Sym)
+/* Return true if the given entry is a register variable */
+/* ### HACK! Fix the ugly type flags! */
+{
+    return ((Sym->Flags & (SC_REGISTER|SC_TYPE)) == SC_REGISTER);
+}
+#else
+#  define SymIsRegVar(Sym)      (((Sym)->Flags & (SC_REGISTER|SC_TYPE)) == SC_REGISTER)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE const char* SymGetAsmName (const SymEntry* Sym)
+/* Return the assembler label name for the symbol (beware: may be NULL!) */
+{
+    return Sym->AsmName;
+}
+#else
+#  define SymGetAsmName(Sym)      ((Sym)->AsmName)
+#endif
+
+void CvtRegVarToAuto (SymEntry* Sym);
+/* Convert a register variable to an auto variable */
 
-void ChangeSymType (SymEntry* Entry, type* Type);
+void ChangeSymType (SymEntry* Entry, Type* T);
 /* Change the type of the given symbol */
 
 void ChangeAsmName (SymEntry* Entry, const char* NewAsmName);