Properly handle references

This commit is contained in:
Daniel Berlin 2000-07-15 17:40:30 +00:00
parent 63bf565122
commit 802db21b61
2 changed files with 29 additions and 12 deletions

View File

@ -1,3 +1,10 @@
2000-07-15 Daniel Berlin <dberlin@redhat.com>
* valops.c (typecmp): Seperate loop into two, add support for
references. This way, we can say a reference to a pointer to a
char is compatible with a pointer to a char. Before, this would
not be true.
2000-07-14 Nicholas Duffek <nsd@redhat.com> 2000-07-14 Nicholas Duffek <nsd@redhat.com>
* ppcbug-rom.c (ppcbug_regnames[]): Make array size implicit. * ppcbug-rom.c (ppcbug_regnames[]): Make array size implicit.

View File

@ -2029,12 +2029,22 @@ typecmp (staticp, t1, t2)
continue; continue;
} }
while (TYPE_CODE (tt1) == TYPE_CODE_PTR /* djb - 20000715 - Until the new type structure is in the
&& (TYPE_CODE (tt2) == TYPE_CODE_ARRAY place, and we can attempt things like implicit conversions,
|| TYPE_CODE (tt2) == TYPE_CODE_PTR)) we need to do this so you can take something like a map<const
char *>, and properly access map["hello"], because the
argument to [] will be a reference to a pointer to a char,
and the arrgument will be a pointer to a char. */
while ( TYPE_CODE(tt1) == TYPE_CODE_REF ||
TYPE_CODE (tt1) == TYPE_CODE_PTR)
{ {
tt1 = check_typedef (TYPE_TARGET_TYPE (tt1)); tt1 = check_typedef( TYPE_TARGET_TYPE(tt1) );
tt2 = check_typedef (TYPE_TARGET_TYPE (tt2)); }
while ( TYPE_CODE(tt2) == TYPE_CODE_ARRAY ||
TYPE_CODE(tt2) == TYPE_CODE_PTR ||
TYPE_CODE(tt2) == TYPE_CODE_REF)
{
tt2 = check_typedef( TYPE_TARGET_TYPE(tt2) );
} }
if (TYPE_CODE (tt1) == TYPE_CODE (tt2)) if (TYPE_CODE (tt1) == TYPE_CODE (tt2))
continue; continue;