This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Properly handle reference arguments in typecmp



This patch has been committed:
00-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.


This allows you to properly access operators and whatnot when they
take a reference to something (like operator [] on maps.).

--Dan
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.20
diff -c -3 -p -w -r1.20 valops.c
*** valops.c	2000/07/12 08:31:49	1.20
--- valops.c	2000/07/15 17:34:37
*************** typecmp (staticp, t1, t2)
*** 2029,2039 ****
  	  continue;
  	}
  
!       while (TYPE_CODE (tt1) == TYPE_CODE_PTR
! 	     && (TYPE_CODE (tt2) == TYPE_CODE_ARRAY
! 		 || TYPE_CODE (tt2) == TYPE_CODE_PTR))
  	{
  	  tt1 = check_typedef (TYPE_TARGET_TYPE (tt1));
  	  tt2 = check_typedef (TYPE_TARGET_TYPE (tt2));
  	}
        if (TYPE_CODE (tt1) == TYPE_CODE (tt2))
--- 2029,2049 ----
  	  continue;
  	}
  
!       /* djb - 20000715 - Until the new type structure is in the
! 	 place, and we can attempt things like implicit conversions,
! 	 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) );
+ 	}
+       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))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]