*** empty log message ***
authorRichard Stallman <rms@gnu.org>
Tue, 5 May 1992 16:04:53 +0000 (16:04 +0000)
committerRichard Stallman <rms@gnu.org>
Tue, 5 May 1992 16:04:53 +0000 (16:04 +0000)
From-SVN: r902

gcc/c-typeck.c

index 464e5f483f9e85feb555cc487fd4f6efe4aae839..e37bb9e0422f19f9170675fe4ea1eb1f560dd8c6 100644 (file)
@@ -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.