aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2010-09-28 09:54:51 +0000
committerNicola Pero <nicola@gcc.gnu.org>2010-09-28 09:54:51 +0000
commit06e67e167d96b750e484be95a0538a8aea488436 (patch)
treec5000560671b3a92abfd539ab07ee2ca154942e5 /gcc
parent06f1db4b1c2e1dbea2e4b6e6f62c4abe5ae7616b (diff)
downloadgcc-06e67e167d96b750e484be95a0538a8aea488436.zip
gcc-06e67e167d96b750e484be95a0538a8aea488436.tar.gz
gcc-06e67e167d96b750e484be95a0538a8aea488436.tar.bz2
In gcc/objc/: 2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/objc/: 2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com> * objc-act.c (encode_type): Do not add 'r' with the next runtime. (encode_aggregate_within): Reorganized code to be more readable. (encode_aggregate_fields): Updated second argument to be 'bool' instead of 'int'. From-SVN: r164680
Diffstat (limited to 'gcc')
-rw-r--r--gcc/objc/ChangeLog7
-rw-r--r--gcc/objc/objc-act.c57
2 files changed, 33 insertions, 31 deletions
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog
index b1fb7bc..e274a86 100644
--- a/gcc/objc/ChangeLog
+++ b/gcc/objc/ChangeLog
@@ -1,3 +1,10 @@
+2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ * objc-act.c (encode_type): Do not add 'r' with the next runtime.
+ (encode_aggregate_within): Reorganized code to be more readable.
+ (encode_aggregate_fields): Updated second argument to be 'bool'
+ instead of 'int'.
+
2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com>
PR objc/45763
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 2752833..39f0b5c 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -8197,7 +8197,7 @@ encode_vector (tree type, int curtype, int format)
}
static void
-encode_aggregate_fields (tree type, int pointed_to, int curtype, int format)
+encode_aggregate_fields (tree type, bool pointed_to, int curtype, int format)
{
tree field = TYPE_FIELDS (type);
@@ -8250,14 +8250,14 @@ encode_aggregate_within (tree type, int curtype, int format, int left,
if (flag_next_runtime)
{
- pointed_to = (ob_size > 0
- ? *(obstack_next_free (&util_obstack) - 1) == '^'
- : 0);
- inline_contents = ((format == OBJC_ENCODE_INLINE_DEFS || generating_instance_variables)
- && (!pointed_to
- || ob_size - curtype == 1
- || (ob_size - curtype == 2
- && *(obstack_next_free (&util_obstack) - 2) == 'r')));
+ if (ob_size > 0 && *(obstack_next_free (&util_obstack) - 1) == '^')
+ pointed_to = true;
+
+ if ((format == OBJC_ENCODE_INLINE_DEFS || generating_instance_variables)
+ && (!pointed_to || ob_size - curtype == 1
+ || (ob_size - curtype == 2
+ && *(obstack_next_free (&util_obstack) - 2) == 'r')))
+ inline_contents = true;
}
else
{
@@ -8279,27 +8279,19 @@ encode_aggregate_within (tree type, int curtype, int format, int left,
inline_contents = true;
else
{
- /* FIXME: It's hard to understand what the following
- code is meant to be doing. It seems that it will
- inline contents even if we are encoding a pointed
- structure and the last characters were 'r^' or just
- '^'.
-
- So it seems that in the end the only case where we
- don't inline contents is '^r', which is a pointer to
- a 'const' structure! If that is the case, the whole
- blob of code could be rewritten in a simpler way.
+ /* Note that the check (ob_size - curtype < 2) prevents
+ infinite recursion when encoding a structure which is
+ a linked list (eg, struct node { struct node *next;
+ }). Each time we follow a pointer, we add one
+ character to ob_size, and curtype is fixed, so after
+ at most two pointers we stop inlining contents and
+ break the loop.
+
+ The other case where we don't inline is "^r", which
+ is a pointer to a constant struct.
*/
- if (c1 == 'r')
- {
- if (ob_size - curtype == 2)
- inline_contents = true;
- }
- else
- {
- if (ob_size - curtype == 1)
- inline_contents = true;
- }
+ if ((ob_size - curtype <= 2) && !(c0 == 'r'))
+ inline_contents = true;
}
}
}
@@ -8372,8 +8364,11 @@ encode_type (tree type, int curtype, int format)
if (type == error_mark_node)
return;
- if (TYPE_READONLY (type))
- obstack_1grow (&util_obstack, 'r');
+ if (!flag_next_runtime)
+ {
+ if (TYPE_READONLY (type))
+ obstack_1grow (&util_obstack, 'r');
+ }
switch (code)
{