+type* ArrayToPtr (const type* T)
+/* Convert an array to a pointer to it's first element */
+{
+ /* Function must only be called for an array */
+ CHECK ((T[0] & T_MASK_TYPE) == T_TYPE_ARRAY);
+
+ /* Return pointer to first element */
+ return PointerTo (T + DECODE_SIZE + 1);
+}
+
+
+
int IsClassInt (const type* T)
/* Return true if this is an integer type */
{
void PrintExprDesc (FILE* F, ExprDesc* E)
/* Print an ExprDesc */
{
- fprintf (F, "Symbol: %s\n", E->Sym? E->Sym->Name : "(none)");
- fprintf (F, "Type: ");
+ fprintf (F, "Symbol: %s\n", E->Sym? E->Sym->Name : "(none)");
if (E->Type) {
+ fprintf (F, "Type: ");
PrintType (F, E->Type);
+ fprintf (F, "\nRaw type: ");
+ PrintRawType (F, E->Type);
} else {
- fprintf (F, "(unknown)");
+ fprintf (F, "Type: (unknown)\n"
+ "Raw type: (unknown)\n");
}
- fprintf (F, "\n");
- fprintf (F, "Value: 0x%08lX\n", E->ConstVal);
- fprintf (F, "Flags: ");
+ fprintf (F, "Value: 0x%08lX\n", E->ConstVal);
+ fprintf (F, "Flags: ");
switch (E->Flags & E_MCTYPE) {
case E_TCONST: fprintf (F, "E_TCONST "); break;
case E_TGLAB: fprintf (F, "E_TGLAB "); break;
if ((E->Flags & E_MCONST) == E_MCONST) {
fprintf (F, "E_MCONST ");
}
- fprintf (F, "\n");
- fprintf (F, "Test: ");
+ fprintf (F, "\nTest: ");
if (E->Test & E_CC) {
fprintf (F, "E_CC ");
}
if (E->Test & E_FORCETEST) {
fprintf (F, "E_FORCETEST ");
}
- fprintf (F, "\n");
- fprintf (F, "Name: 0x%08lX\n", E->Name);
+ fprintf (F, "\nName: 0x%08lX\n", E->Name);
}
/* Read the expression we have to cast */
k = hie10 (lval);
- /* If the expression is a function or an array, treat it as
- * "pointer to type"
+ /* If the expression is a function, treat it as pointer to function.
+ * If the expression is an array, treat it as pointer to first element.
*/
- if (IsTypeFunc (lval->Type) || IsTypeArray (lval->Type)) {
+ if (IsTypeFunc (lval->Type)) {
lval->Type = PointerTo (lval->Type);
+ } else if (IsTypeArray (lval->Type)) {
+ lval->Type = ArrayToPtr (lval->Type);
}
/* Remember the old type */