]> git.sur5r.net Git - cc65/blobdiff - src/cc65/datatype.c
Fixed two compiler warnings.
[cc65] / src / cc65 / datatype.c
index fc71d3df2a1176768effb8c09be61c5d65c10566..0d7b27c6021b0aec761a2cfd340b9b15117fe1fc 100644 (file)
@@ -90,7 +90,7 @@ unsigned TypeLen (const Type* T)
 
 
 
-Type* TypeCpy (Type* Dest, const Type* Src)
+Type* TypeCopy (Type* Dest, const Type* Src)
 /* Copy a type string */
 {
     Type* Orig = Dest;
@@ -187,7 +187,7 @@ Type* GetImplicitFuncType (void)
     F->TagTab = &EmptySymTab;
 
     /* Fill the type string */
-    T[0].C   = T_FUNC;
+    T[0].C   = T_FUNC | CodeAddrSizeQualifier ();
     T[0].A.P = F;
     T[1].C   = T_INT;
     T[2].C   = T_END;
@@ -249,6 +249,7 @@ void PrintType (FILE* F, const Type* T)
         C = PrintTypeComp (F, C, T_QUAL_NEAR, "__near__");
         C = PrintTypeComp (F, C, T_QUAL_FAR, "__far__");
         C = PrintTypeComp (F, C, T_QUAL_FASTCALL, "__fastcall__");
+        C = PrintTypeComp (F, C, T_QUAL_CDECL, "__cdecl__");
 
        /* Signedness. Omit the signedness specifier for long and int */
                if ((C & T_MASK_TYPE) != T_TYPE_INT && (C & T_MASK_TYPE) != T_TYPE_LONG) {
@@ -333,6 +334,9 @@ void PrintFuncSig (FILE* F, const char* Name, Type* T)
     if (IsQualFastcall (T)) {
        fprintf (F, " __fastcall__");
     }
+    if (IsQualCDecl (T)) {
+       fprintf (F, " __cdecl__");
+    }
     fprintf (F, " %s (", Name);
 
     /* Parameters */
@@ -548,14 +552,11 @@ Type* Indirect (Type* T)
 
 
 
-Type* ArrayToPtr (const Type* T)
+Type* ArrayToPtr (Type* T)
 /* Convert an array to a pointer to it's first element */
 {
-    /* Function must only be called for an array */
-    CHECK (IsTypeArray (T));
-
     /* Return pointer to first element */
-    return PointerTo (T + 1);
+    return PointerTo (GetElementType (T));
 }
 
 
@@ -703,8 +704,10 @@ Type* PtrConversion (Type* T)
  * return T.
  */
 {
-    if (IsTypeFunc (T) || IsTypeArray (T)) {
+    if (IsTypeFunc (T)) {
                return PointerTo (T);
+    } else if (IsTypeArray (T)) {
+        return ArrayToPtr (T);
     } else {
         return T;
     }
@@ -712,25 +715,21 @@ Type* PtrConversion (Type* T)
 
 
 
-TypeCode CodeAddrSizeQualifier (void)
-/* Return T_QUAL_NEAR or T_QUAL_FAR depending on the code address size */
+TypeCode AddrSizeQualifier (unsigned AddrSize)
+/* Return T_QUAL_NEAR or T_QUAL_FAR depending on the address size */
 {
-    if (CodeAddrSize == ADDR_SIZE_FAR) {
-        return T_QUAL_FAR;
-    } else {
-        return T_QUAL_NEAR;
-    }
-}
+    switch (AddrSize) {
 
+        case ADDR_SIZE_ABS:
+            return T_QUAL_NEAR;
 
+        case ADDR_SIZE_FAR:
+            return T_QUAL_FAR;
+
+        default:
+            Error ("Invalid address size");
+            return T_QUAL_NEAR;
 
-TypeCode DataAddrSizeQualifier (void)
-/* Return T_QUAL_NEAR or T_QUAL_FAR depending on the data address size */
-{
-    if (DataAddrSize == ADDR_SIZE_FAR) {
-        return T_QUAL_FAR;
-    } else {
-        return T_QUAL_NEAR;
     }
 }