(finish_incomplete_decl): Warn if completing an array that wasn't declared extern.
authorRichard Kenner <kenner@gcc.gnu.org>
Tue, 16 Jan 1996 01:05:06 +0000 (20:05 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Tue, 16 Jan 1996 01:05:06 +0000 (20:05 -0500)
(finish_incomplete_decl): Warn if completing an array that wasn't
declared extern.  Simplify test for whether completion is needed.

From-SVN: r11003

gcc/c-decl.c

index 121424db0324769a5d601b0aa62f043be80debb4..0afbcd00ba60186dfd1adc260096f3d054ab6a90 100644 (file)
@@ -772,13 +772,16 @@ void
 finish_incomplete_decl (decl)
      tree decl;
 {
-  if (TREE_CODE (decl) == VAR_DECL && TREE_TYPE (decl) != error_mark_node)
+  if (TREE_CODE (decl) == VAR_DECL)
     {
       tree type = TREE_TYPE (decl);
-      if (TREE_CODE (type) == ARRAY_TYPE
-         && TYPE_DOMAIN (type) == 0
-         && TREE_CODE (decl) != TYPE_DECL)
+      if (type != error_mark_node
+         && TREE_CODE (type) == ARRAY_TYPE
+         && TYPE_DOMAIN (type) == 0)
        {
+         if (! DECL_EXTERNAL (decl))
+           warning_with_decl (decl, "array `%s' assumed to have one element");
+
          complete_array_type (type, NULL_TREE, 1);
 
          layout_decl (decl, 0);