OSDN Git Service

(finish_struct): If pedantic, also warn if struct/union has no named
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 Aug 1996 21:46:05 +0000 (21:46 +0000)
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 Aug 1996 21:46:05 +0000 (21:46 +0000)
members.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@12612 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c-decl.c

index 2ed017f..cb59a08 100644 (file)
@@ -5533,9 +5533,17 @@ finish_struct (t, fieldlist, attributes)
 
   old_momentary = suspend_momentary ();
 
-  if (fieldlist == 0 && pedantic)
-    pedwarn ((TREE_CODE (t) == UNION_TYPE ? "union has no members"
-             : "structure has no members"));
+  if (pedantic)
+    {
+      for (x = fieldlist; x; x = TREE_CHAIN (x))
+       if (DECL_NAME (x) != 0)
+         break;
+
+      if (x == 0)
+       pedwarn ("%s has no %smembers",
+                (TREE_CODE (t) == UNION_TYPE ? "union" : "structure"),
+                (fieldlist ? "named " : ""));
+    }
 
   /* Install struct as DECL_CONTEXT of each field decl.
      Also process specified field sizes.