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
4 changed files with 30 additions and 13 deletions
|
@ -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)
|
int IsClassInt (const type* T)
|
||||||
/* Return true if this is an integer type */
|
/* Return true if this is an integer type */
|
||||||
{
|
{
|
||||||
|
|
|
@ -270,6 +270,9 @@ type* Indirect (type* Type);
|
||||||
* given type points to.
|
* given type points to.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
type* ArrayToPtr (const type* Type);
|
||||||
|
/* Convert an array to a pointer to it's first element */
|
||||||
|
|
||||||
#if defined(HAVE_INLINE)
|
#if defined(HAVE_INLINE)
|
||||||
INLINE int IsTypeChar (const type* T)
|
INLINE int IsTypeChar (const type* T)
|
||||||
/* Return true if this is a character type */
|
/* Return true if this is a character type */
|
||||||
|
|
|
@ -60,13 +60,15 @@ void PrintExprDesc (FILE* F, ExprDesc* E)
|
||||||
/* Print an ExprDesc */
|
/* Print an ExprDesc */
|
||||||
{
|
{
|
||||||
fprintf (F, "Symbol: %s\n", E->Sym? E->Sym->Name : "(none)");
|
fprintf (F, "Symbol: %s\n", E->Sym? E->Sym->Name : "(none)");
|
||||||
fprintf (F, "Type: ");
|
|
||||||
if (E->Type) {
|
if (E->Type) {
|
||||||
|
fprintf (F, "Type: ");
|
||||||
PrintType (F, E->Type);
|
PrintType (F, E->Type);
|
||||||
|
fprintf (F, "\nRaw type: ");
|
||||||
|
PrintRawType (F, E->Type);
|
||||||
} else {
|
} 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, "Value: 0x%08lX\n", E->ConstVal);
|
||||||
fprintf (F, "Flags: ");
|
fprintf (F, "Flags: ");
|
||||||
switch (E->Flags & E_MCTYPE) {
|
switch (E->Flags & E_MCTYPE) {
|
||||||
|
@ -94,18 +96,16 @@ void PrintExprDesc (FILE* F, ExprDesc* E)
|
||||||
if ((E->Flags & E_MCONST) == E_MCONST) {
|
if ((E->Flags & E_MCONST) == E_MCONST) {
|
||||||
fprintf (F, "E_MCONST ");
|
fprintf (F, "E_MCONST ");
|
||||||
}
|
}
|
||||||
fprintf (F, "\n");
|
|
||||||
|
|
||||||
fprintf (F, "Test: ");
|
fprintf (F, "\nTest: ");
|
||||||
if (E->Test & E_CC) {
|
if (E->Test & E_CC) {
|
||||||
fprintf (F, "E_CC ");
|
fprintf (F, "E_CC ");
|
||||||
}
|
}
|
||||||
if (E->Test & E_FORCETEST) {
|
if (E->Test & E_FORCETEST) {
|
||||||
fprintf (F, "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 */
|
/* Read the expression we have to cast */
|
||||||
k = hie10 (lval);
|
k = hie10 (lval);
|
||||||
|
|
||||||
/* If the expression is a function or an array, treat it as
|
/* If the expression is a function, treat it as pointer to function.
|
||||||
* "pointer to type"
|
* 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);
|
lval->Type = PointerTo (lval->Type);
|
||||||
|
} else if (IsTypeArray (lval->Type)) {
|
||||||
|
lval->Type = ArrayToPtr (lval->Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remember the old type */
|
/* Remember the old type */
|
||||||
|
|
Loading…
Add table
Reference in a new issue