mirror of
https://github.com/cc65/cc65.git
synced 2024-12-22 12:30:41 +00:00
Replaced the solution for the array conversion problem by a better one.
git-svn-id: svn://svn.cc65.org/cc65/trunk@1784 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
421c8771dc
commit
5f666a19b8
@ -598,6 +598,18 @@ type* Indirect (type* T)
|
||||
|
||||
|
||||
|
||||
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 */
|
||||
{
|
||||
|
@ -270,6 +270,9 @@ type* Indirect (type* Type);
|
||||
* given type points to.
|
||||
*/
|
||||
|
||||
type* ArrayToPtr (const type* Type);
|
||||
/* Convert an array to a pointer to it's first element */
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE int IsTypeChar (const type* T)
|
||||
/* Return true if this is a character type */
|
||||
|
@ -59,16 +59,18 @@ void MakeConstIntExpr (ExprDesc* Expr, long Value)
|
||||
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;
|
||||
@ -94,18 +96,16 @@ void PrintExprDesc (FILE* F, ExprDesc* E)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,11 +73,13 @@ int TypeCast (ExprDesc* lval)
|
||||
/* 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 */
|
||||
|
Loading…
Reference in New Issue
Block a user