]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/c/c-typeck.c
re PR c/51849 (-Wc99-compat would be considered useful)
[thirdparty/gcc.git] / gcc / c / c-typeck.c
index f8a231617aec167561bcec5b435e4a8bf9fcab51..0ed92c699f753feb5a6968a3dda6c051b3fc01f0 100644 (file)
@@ -2510,7 +2510,7 @@ build_array_ref (location_t loc, tree array, tree index)
            return error_mark_node;
        }
 
-      if (pedantic)
+      if (pedantic || warn_c90_c99_compat)
        {
          tree foo = array;
          while (TREE_CODE (foo) == COMPONENT_REF)
@@ -2518,9 +2518,10 @@ build_array_ref (location_t loc, tree array, tree index)
          if (TREE_CODE (foo) == VAR_DECL && C_DECL_REGISTER (foo))
            pedwarn (loc, OPT_Wpedantic,
                     "ISO C forbids subscripting %<register%> array");
-         else if (!flag_isoc99 && !lvalue_p (foo))
-           pedwarn (loc, OPT_Wpedantic,
-                    "ISO C90 forbids subscripting non-lvalue array");
+         else if (!lvalue_p (foo))
+           pedwarn_c90 (loc, OPT_Wpedantic,
+                        "ISO C90 forbids subscripting non-lvalue "
+                        "array");
        }
 
       type = TREE_TYPE (TREE_TYPE (array));