diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2008-10-28 20:18:00 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2008-10-28 20:18:00 +0000 |
commit | 6f10501a4a2f1fcc2e3d7c2aa7b1ed122fd95390 (patch) | |
tree | 06d090dc4836c36d5a58c77e7b1f5a431e069cd0 /gnu | |
parent | 747840f33ef30df6f86d63efee38b468ead5f495 (diff) |
Avoid infinite recursion in search_string_def() and search_pointer_def(),
PR #5033; gcc 2.95 will need a similar fix (soon).
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/gcc/gcc/protector.c | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/gnu/usr.bin/gcc/gcc/protector.c b/gnu/usr.bin/gcc/gcc/protector.c index d2009371d9a..8cda801293c 100644 --- a/gnu/usr.bin/gcc/gcc/protector.c +++ b/gnu/usr.bin/gcc/gcc/protector.c @@ -426,16 +426,29 @@ search_string_def (type) case UNION_TYPE: case QUAL_UNION_TYPE: case RECORD_TYPE: - /* Output the name, type, position (in bits), size (in bits) of each - field. */ - for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) + if (! TREE_VISITED (type)) { - /* Omit here local type decls until we know how to support them. */ - if ((TREE_CODE (tem) == TYPE_DECL) - || (TREE_CODE (tem) == VAR_DECL && TREE_STATIC (tem))) - continue; + /* mark the type as having been visited already */ + TREE_VISITED (type) = 1; + + /* Output the name, type, position (in bits), size (in bits) of each + field. */ + for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) + { + /* Omit here local type decls until we know how to support + them. */ + if ((TREE_CODE (tem) == TYPE_DECL) + || (TREE_CODE (tem) == VAR_DECL && TREE_STATIC (tem))) + continue; + + if (search_string_def(TREE_TYPE(tem))) + { + TREE_VISITED (type) = 0; + return TRUE; + } + } - if (search_string_def(TREE_TYPE(tem))) return TRUE; + TREE_VISITED (type) = 0; } break; @@ -518,16 +531,29 @@ search_pointer_def (type) case UNION_TYPE: case QUAL_UNION_TYPE: case RECORD_TYPE: - /* Output the name, type, position (in bits), size (in bits) of each - field. */ - for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) + if (! TREE_VISITED (type)) { - /* Omit here local type decls until we know how to support them. */ - if ((TREE_CODE (tem) == TYPE_DECL) - || (TREE_CODE (tem) == VAR_DECL && TREE_STATIC (tem))) - continue; + /* mark the type as having been visited already */ + TREE_VISITED (type) = 1; + + /* Output the name, type, position (in bits), size (in bits) of each + field. */ + for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) + { + /* Omit here local type decls until we know how to support + them. */ + if ((TREE_CODE (tem) == TYPE_DECL) + || (TREE_CODE (tem) == VAR_DECL && TREE_STATIC (tem))) + continue; + + if (search_pointer_def(TREE_TYPE(tem))) + { + TREE_VISITED (type) = 0; + return TRUE; + } + } - if (search_pointer_def (TREE_TYPE(tem))) return TRUE; + TREE_VISITED (type) = 0; } break; |