aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1996-10-21 07:59:10 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1996-10-21 07:59:10 -0400
commitaed11452282b9f1f0f2f18c7656e17cbb5955d94 (patch)
treeb7223d9ae09edace4425219de78ab64bc85794da
parent04d23d7c9f04fd64de62c839e63426760254df68 (diff)
downloadgcc-aed11452282b9f1f0f2f18c7656e17cbb5955d94.zip
gcc-aed11452282b9f1f0f2f18c7656e17cbb5955d94.tar.gz
gcc-aed11452282b9f1f0f2f18c7656e17cbb5955d94.tar.bz2
(build_array_ref): If -Wchar-subscripts, also warn in case when
pointer is being indexed. From-SVN: r12983
-rw-r--r--gcc/c-typeck.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index ec26185..9a0030d 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)
{