This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: objc testcase patches
On 28 Jan, 2004, at 1.00, Jim Wilson wrote:
I checked in the encode-[23].m patches. As for proto-qual-1.c ...
For x86-linux, we get
_OBJC_METH_VAR_TYPE_9:
.string "O@16@0:4NR@8o^^S12"
So offs2 is 8, offs3 is 12, and totsize is 16. Thus
offs2+sizeof(id)==offs3
8+4==12
is true, and also
offs3+sizeof(unsigned)==totsize
12+4==16
is true.
For ia64-linux, we get
_OBJC_METH_VAR_TYPE_9:
stringz "O@32@0:8NR@16o^^S24"
So offs2 is 16, offs3 is 24, and totsize is 32. Thus
offs2+sizeof(id)==offs3
16+8==24
is true, but
offs3+sizeof(unsigned)==totsize
24+4==32
is not true. This is because we have 4 bytes of padding on an LP64
target.
How about the following?
Index: proto-qual-1.m
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/objc.dg/proto-qual-1.m,v
retrieving revision 1.2
diff -c -3 -p -r1.2 proto-qual-1.m
*** proto-qual-1.m 25 Sep 2003 01:26:01 -0000 1.2
--- proto-qual-1.m 28 Jan 2004 18:55:10 -0000
***************
*** 8,13 ****
--- 8,17 ----
#include <objc/objc-api.h>
#endif
+ /* The encoded parameter sizes will be rounded up to match pointer
alignment. */
+ #define ROUND(s,a) (a * ((s + a - 1) / a))
+ #define aligned_sizeof(T) ROUND(sizeof(T),__alignof(void *))
+
extern int sscanf(const char *str, const char *format, ...);
extern void abort(void);
#define CHECK_IF(expr) if(!(expr)) abort()
*************** static void scan_initial(const char *pat
*** 34,48 ****
totsize = offs0 = offs1 = offs2 = offs3 = offs4 = offs5 = offs6 =
offs7 = (unsigned)-1;
sscanf(meth->types, pattern, &totsize, &offs0, &offs1, &offs2,
&offs3,
&offs4, &offs5, &offs6, &offs7);
! CHECK_IF(!offs0 && offs1 == sizeof(id) && offs2 == offs1 +
sizeof(SEL) && totsize >= offs2);
}
int main(void) {
meth = [proto descriptionForInstanceMethod:
@selector(address:with:)];
scan_initial("O@%u@%u:%uNR@%uo^^S%u");
! CHECK_IF(offs3 == offs2 + sizeof(id) && totsize == offs3 +
sizeof(unsigned));
meth = [proto descriptionForClassMethod:
@selector(retainArgument:with:)];
scan_initial("Vv%u@%u:%uOo@%un^*%u");
! CHECK_IF(offs3 == offs2 + sizeof(id) && totsize == offs3 +
sizeof(char **));
return 0;
}
--- 38,52 ----
totsize = offs0 = offs1 = offs2 = offs3 = offs4 = offs5 = offs6 =
offs7 = (unsigned)-1;
sscanf(meth->types, pattern, &totsize, &offs0, &offs1, &offs2,
&offs3,
&offs4, &offs5, &offs6, &offs7);
! CHECK_IF(!offs0 && offs1 == aligned_sizeof(id) && offs2 == offs1 +
aligned_sizeof(SEL) && totsize >= offs2);
}
int main(void) {
meth = [proto descriptionForInstanceMethod:
@selector(address:with:)];
scan_initial("O@%u@%u:%uNR@%uo^^S%u");
! CHECK_IF(offs3 == offs2 + aligned_sizeof(id) && totsize == offs3 +
aligned_sizeof(unsigned));
meth = [proto descriptionForClassMethod:
@selector(retainArgument:with:)];
scan_initial("Vv%u@%u:%uOo@%un^*%u");
! CHECK_IF(offs3 == offs2 + aligned_sizeof(id) && totsize == offs3 +
aligned_sizeof(char **));
return 0;
}
--------------------------------------------------------------
Ziemowit Laski 1 Infinite Loop, MS 301-2K
Mac OS X Compiler Group Cupertino, CA USA 95014-2083
Apple Computer, Inc. +1.408.974.6229 Fax .5477