From d6272e453df01a14b586a1ca45fcb90aed2817c9 Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Wed, 16 Jun 1993 20:27:18 +0000 Subject: [PATCH] (check_format): Don't crash if cur_type is an error_mark. Handle identifier_node as the TYPE_NAME. From-SVN: r4682 --- gcc/c-typeck.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index d7bd4ad521d..a10fb0abcc3 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -1794,12 +1794,18 @@ check_format (info, params) this = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (wanted_type))); that = 0; - if (TYPE_NAME (cur_type) != 0 + if (TREE_CODE (cur_type) != ERROR_MARK + && TYPE_NAME (cur_type) != 0 && TREE_CODE (cur_type) != INTEGER_TYPE && !(TREE_CODE (cur_type) == POINTER_TYPE - && TREE_CODE (TREE_TYPE (cur_type)) == INTEGER_TYPE) - && DECL_NAME (TYPE_NAME (cur_type)) != 0) - that = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (cur_type))); + && TREE_CODE (TREE_TYPE (cur_type)) == INTEGER_TYPE)) + { + if (TREE_CODE (TYPE_NAME (cur_type)) == TYPE_DECL + && DECL_NAME (TYPE_NAME (cur_type)) != 0) + that = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (cur_type))); + else + that = IDENTIFIER_POINTER (TYPE_NAME (cur_type)); + } /* A nameless type can't possibly match what the format wants. So there will be a warning for it. -- 2.30.2