This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Robustify TYPE_LANG_SPECIFIC condition check
- From: Ziemowit Laski <zlaski at apple dot com>
- To: "gcc-patches at gcc dot gnu dot org Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 9 Dec 2004 19:01:58 -0800
- Subject: PATCH: Robustify TYPE_LANG_SPECIFIC condition check
This is a consequence of ObjC now using TYPE_LANG_SPECIFIC to store its
own information. Turns out that lookup_field() assumes that
TYPE_LANG_SPECIFIC
assumes will always have its 's' field initialized, which is not true
for ObjC structs.
OK for mainline?
--Zem
[gcc/ChangeLog]
2004-12-09 Ziemowit Laski <zlaski@apple.com>
* c-typeck.c (lookup_field): Check if a TYPE_LANG_SPECIFIC
pointer field is set before dereferencing it.
Index: gcc/c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.403
diff -u -3 -p -r1.403 c-typeck.c
--- gcc/c-typeck.c 8 Dec 2004 00:11:47 -0000 1.403
+++ gcc/c-typeck.c 10 Dec 2004 02:57:16 -0000
@@ -1377,7 +1377,7 @@ lookup_field (tree decl, tree component)
find the element. Otherwise, do a linear search.
TYPE_LANG_SPECIFIC
will always be set for structures which have many elements. */
- if (TYPE_LANG_SPECIFIC (type))
+ if (TYPE_LANG_SPECIFIC (type) && TYPE_LANG_SPECIFIC (type)->s)
{
int bot, top, half;
tree *field_array = &TYPE_LANG_SPECIFIC (type)->s->elts[0];