summaryrefslogtreecommitdiff
path: root/libobjc/encoding.c
diff options
context:
space:
mode:
authornicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-27 19:22:13 +0000
committernicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-27 19:22:13 +0000
commitf8ee0563dfbffc5c24cc4424fca8cd070ee6121c (patch)
tree251b23a8c4eafe1915cb28c5bfe7d86fc70d2045 /libobjc/encoding.c
parent6d0948444cac267870c0d19ac355d7560a62ed37 (diff)
downloadgcc-f8ee0563dfbffc5c24cc4424fca8cd070ee6121c.tar.gz
In gcc/:
2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com> * doc/objc.texi (Type encoding): Added the new 'long double' (D) code. Added byref, which was missing in the list of codes. Explain that enumeration values are encoded as the integer type that the compiler uses to store them. Explain and make examples of how 'const' interacts with pointers, and the complication of the encoding of 'const char *'. (Legacy type encoding): New subsection, explaining that GCC emits incorrect type encodings for the NeXT runtime for compatibility reasons. (@@encode): New subsection, explaining @encode and particularly that protocol qualifiers are not recognized inside an @encode() expression. (Method signatures): New subsection, explaining how method signatures are encoded. In gcc/objc/: 2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com> PR objc/45763 PR objc/25450 PR objc/25464 * objc-act.c: Improved comments for encoding functions. (encode_aggregate_within): For the GNU runtime, rewritten some obsfuscated code to clarify the various cases. (encode_aggregate): Function removed. (encode_array): Generate an error if asked to encode an incomplete array as part of generating instance variables. Else, when encoding an incomplete array inside a structure, encode it as an array of zero size. (encode_pointer): For the GNU runtime, fixed encoding 'BOOL *' as '^c' instead of '*'. (encode_gnu_bitfield): Encode enumerated types exactly in the same type as integer types instead of using a hardcoded 'i'. If asked to encode a non-integer type as a bitfield, do not abort compilation immediately; instead generate an error, then skip the type. (encode_type): Use a 'switch' instead of a sequence of 'if's. Added a 'default' clause that gets executed if the type can not be matched, and that encodes it as '?' (unknown) and produces a warning. For the GNU runtime, encode enumerated types exactly in the same way as integer types instead of using a hardcoded 'i'. Encode long double as 'D'. Encode 128-bit integers as 'T' or 't'. Encode C++ reference types as pointers. Call encode_vector to encode vectors. (encode_vector): New function. 2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com> Merge from 'apple/trunk' branch on FSF servers. I modified the changes to be used only when compiling for the NeXT runtime. 2005-10-10 Fariborz Jahanian <fjahanian@apple.com> Radar 4301047 * objc-act.c (encode_type): Remove the hack. 2005-07-20 Ziemowit Laski <zlaski@apple.com> Radar 4136935 * objc-act.c (pointee_is_readonly): New function. (encode_pointer, encode_aggregate_within, encode_type): Attempt to emulate GCC 3.3 when generating type encodings. In gcc/testsuite/: 2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com> PR objc/25464 * objc.dg/type-size-3.m: New test. 2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com> PR objc/45763 * objc.dg/encode-1.m: Execute the test with the GNU runtime as well. 2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com> PR objc/25450 * objc.dg/encode-3.m: Updated for fix of encoding of enums. * objc.dg/type-size-2.m: Same change. * obj-c++.dg/encode-5.mm: Same change. 2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com> Merge from 'apple/trunk' branch on FSF servers. The original Changelogs are below. * objc.dg/encode-6.m: Execute the test only with the GNU runtime. * objc.dg/encode-6-next.m: New file (from encode-6.m in the branch). * objc.dg/encode-7-next.m: New file (from encode-7.m in the branch). * objc.dg/encode-7-next-64bit.m: New file (from encode-7-64bit.m in the branch). * objc.dg/proto-qual-1.m: Test the 3.3 ABI on NeXT (from proto-qual-1.m in the branch) and the normal ABI on GNU. * objc.dg/threedotthree-abi-1.m: New file (from the branch). Run the test only with the NeXT runtime. * obj-c++/encode-1.mm: Execute the test only with the GNU runtime. * obj-c++/encode-1-next.mm: New file (from encode-1.mm in the branch). * obj-c++.dg/threedotthree-abi-1.mm: New file (from the branch). Run the test only with the NeXT runtime. 2006-03-30 Fariborz Jahanian <fjahanian@apple.com> Radar 4492973 * objc.dg/encode-7-64bit.m: New. * objc.dg/encode-7.m: Skip if -m64. 2005-10-19 Fariborz Jahanian <fjahanian@apple.com> Radar 4301047 * objc.dg/proto-qual-1.m: Fix test to match 3.3 ABI * obj-c++.dg/threedotthree-abi-1.mm: New * objc.dg/threedotthree-abi-1.m: New 2005-07-20 Ziemowit Laski <zlaski@apple.com> Radar 4136935 * obj-c++.dg/encode-1.mm: Tweak encodings to match fix. * objc.dg/encode-6.m: Likewise. * objc.dg/encode-7.m: New test case. In libobjc/: 2010-09-26 Nicola Pero <nicola.pero@meta-innovation.com> * encoding.c (objc_sizeof_type): Added support for vector type and for double long types. (objc_alignof_type): Same change. (objc_skip_typespec): Same change. * objc/encoding.h (_C_GCINVISIBLE): Use '|' for _C_GCINVISIBLE instead of '!' since '!' is already used for _C_VECTOR. * objc/objc-api.h (_C_LNG_DBL): Added. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164659 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libobjc/encoding.c')
-rw-r--r--libobjc/encoding.c79
1 files changed, 77 insertions, 2 deletions
diff --git a/libobjc/encoding.c b/libobjc/encoding.c
index 35c95521b80..d417b87396e 100644
--- a/libobjc/encoding.c
+++ b/libobjc/encoding.c
@@ -148,6 +148,8 @@ objc_sizeof_type (const char *type)
/* Skip the variable name if any */
if (*type == '"')
{
+ /* FIXME: How do we know we won't read beyond the end of the
+ string. Here and in the rest of the file! */
for (type++; *type++ != '"';)
/* do nothing */;
}
@@ -217,6 +219,10 @@ objc_sizeof_type (const char *type)
return sizeof (double);
break;
+ case _C_LNG_DBL:
+ return sizeof (long double);
+ break;
+
case _C_VOID:
return sizeof (void);
break;
@@ -236,6 +242,19 @@ objc_sizeof_type (const char *type)
}
break;
+ case _C_VECTOR:
+ {
+ /* Skip the '!'. */
+ type++;
+ /* Skip the '['. */
+ type++;
+
+ /* The size in bytes is the following number. */
+ int size = atoi (type);
+ return size;
+ }
+ break;
+
case _C_BFLD:
{
/* The new encoding of bitfields is: b 'position' 'type' 'size' */
@@ -318,6 +337,10 @@ objc_sizeof_type (const char *type)
case _C_DBL:
return sizeof (_Complex double);
break;
+
+ case _C_LNG_DBL:
+ return sizeof (_Complex long double);
+ break;
default:
{
@@ -418,6 +441,10 @@ objc_alignof_type (const char *type)
return __alignof__ (double);
break;
+ case _C_LNG_DBL:
+ return __alignof__ (long double);
+ break;
+
case _C_PTR:
case _C_ATOM:
case _C_CHARPTR:
@@ -429,6 +456,23 @@ objc_alignof_type (const char *type)
/* do nothing */;
return objc_alignof_type (type);
+ case _C_VECTOR:
+ {
+ /* Skip the '!'. */
+ type++;
+ /* Skip the '['. */
+ type++;
+
+ /* Skip the size. */
+ while (isdigit ((unsigned char)*type))
+ type++;
+
+ /* Skip the ','. */
+ type++;
+
+ /* The alignment in bytes is the following number. */
+ return atoi (type);
+ }
case _C_STRUCT_B:
case _C_UNION_B:
{
@@ -496,6 +540,10 @@ objc_alignof_type (const char *type)
case _C_DBL:
return __alignof__ (_Complex double);
break;
+
+ case _C_LNG_DBL:
+ return __alignof__ (_Complex long double);
+ break;
default:
{
@@ -631,6 +679,7 @@ objc_skip_typespec (const char *type)
case _C_ULNG_LNG:
case _C_FLT:
case _C_DBL:
+ case _C_LNG_DBL:
case _C_VOID:
case _C_UNDEF:
return ++type;
@@ -642,7 +691,6 @@ objc_skip_typespec (const char *type)
case _C_ARY_B:
/* skip digits, typespec and closing ']' */
-
while (isdigit ((unsigned char)*++type))
;
type = objc_skip_typespec (type);
@@ -654,6 +702,30 @@ objc_skip_typespec (const char *type)
return 0;
}
+ case _C_VECTOR:
+ /* Skip '!' */
+ type++;
+ /* Skip '[' */
+ type++;
+ /* Skip digits (size) */
+ while (isdigit ((unsigned char)*type))
+ type++;
+ /* Skip ',' */
+ type++;
+ /* Skip digits (alignment) */
+ while (isdigit ((unsigned char)*type))
+ type++;
+ /* Skip typespec. */
+ type = objc_skip_typespec (type);
+ /* Skip closing ']'. */
+ if (*type == _C_ARY_E)
+ return ++type;
+ else
+ {
+ _objc_abort ("bad vector type %s\n", type);
+ return 0;
+ }
+
case _C_BFLD:
/* The new encoding of bitfields is: b 'position' 'type' 'size' */
while (isdigit ((unsigned char)*++type))
@@ -700,6 +772,8 @@ objc_skip_typespec (const char *type)
/*
Skip an offset as part of a method encoding. This is prepended by a
'+' if the argument is passed in registers.
+
+ FIXME: The compiler never generates '+'.
*/
const char *
objc_skip_offset (const char *type)
@@ -883,7 +957,7 @@ objc_get_type_qualifiers (const char *type)
the presence of bitfields inside the structure. */
void
objc_layout_structure (const char *type,
- struct objc_struct_layout *layout)
+ struct objc_struct_layout *layout)
{
const char *ntype;
@@ -979,6 +1053,7 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout)
bfld_field_size = atoi (objc_skip_typespec (bfld_type));
}
+ /* The following won't work for vectors. */
#ifdef BIGGEST_FIELD_ALIGNMENT
desired_align = MIN (desired_align, BIGGEST_FIELD_ALIGNMENT);
#endif