From aed11452282b9f1f0f2f18c7656e17cbb5955d94 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Mon, 21 Oct 1996 07:59:10 -0400 Subject: [PATCH] (build_array_ref): If -Wchar-subscripts, also warn in case when pointer is being indexed. From-SVN: r12983 --- gcc/c-typeck.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index ec261853d02..9a0030d5a43 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -1451,6 +1451,14 @@ build_array_ref (array, index) tree ar = default_conversion (array); tree ind = default_conversion (index); + /* Do the same warning check as above, but only on the part that's + syntactically the index and only if it is also semantically + the index. */ + if (warn_char_subscripts + && TREE_CODE (TREE_TYPE (index)) == INTEGER_TYPE + && TYPE_MAIN_VARIANT (TREE_TYPE (index)) == char_type_node) + warning ("subscript has type `char'"); + /* Put the integer in IND to simplify error checking. */ if (TREE_CODE (TREE_TYPE (ar)) == INTEGER_TYPE) { -- 2.30.2