aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1992-05-05 16:04:53 +0000
committerRichard Stallman <rms@gnu.org>1992-05-05 16:04:53 +0000
commitfdeefd4955cc481a017a88b9300921ec0d649d43 (patch)
treef4bb3ed1d7f54df7002808a767175f743e254502 /gcc
parentaaf9712e79c6bdfcdb337d621e80e517aebd955b (diff)
downloadgcc-fdeefd4955cc481a017a88b9300921ec0d649d43.zip
gcc-fdeefd4955cc481a017a88b9300921ec0d649d43.tar.gz
gcc-fdeefd4955cc481a017a88b9300921ec0d649d43.tar.bz2
*** empty log message ***
From-SVN: r902
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-typeck.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 464e5f4..e37bb9e 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -1147,13 +1147,6 @@ build_array_ref (array, index)
{
tree rval, type;
- if (index != error_mark_node
- && TREE_CODE (TREE_TYPE (index)) != INTEGER_TYPE)
- {
- error ("array subscript is not an integer");
- return error_mark_node;
- }
-
/* Subscripting with type char is likely to lose
on a machine where chars are signed.
So warn on any machine, but optionally.
@@ -1167,6 +1160,13 @@ build_array_ref (array, index)
/* Apply default promotions *after* noticing character types. */
index = default_conversion (index);
+ /* Require integer *after* promotion, for sake of enums. */
+ if (TREE_CODE (TREE_TYPE (index)) != INTEGER_TYPE)
+ {
+ error ("array subscript is not an integer");
+ return error_mark_node;
+ }
+
/* An array that is indexed by a non-constant
cannot be stored in a register; we must be able to do
address arithmetic on its address.