This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to improve diagnostic for memberless structs
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 7 Nov 2004 00:35:03 +0000 (UTC)
- Subject: Patch to improve diagnostic for memberless structs
The diagnostic for structures or unions with no members or no named
members was made up from fragments (bad for i18n) in an easily fixable
way. This patch fixes it. The testcases are the recently added
gcc.dg/struct-empty-*.c.
Bootstrapped with no regressions on i686-pc-linux-gnu. Applied to
mainline.
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
joseph@codesourcery.com (CodeSourcery mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)
2004-11-07 Joseph S. Myers <joseph@codesourcery.com>
* c-decl.c (finish_struct): Use complete sentences for diagnostic
for structures or unions with no members or named members.
diff -rupN GCC.orig/gcc/c-decl.c GCC/gcc/c-decl.c
--- GCC.orig/gcc/c-decl.c 2004-11-04 22:33:23.000000000 +0000
+++ GCC/gcc/c-decl.c 2004-11-06 16:25:41.000000000 +0000
@@ -5157,9 +5157,22 @@ finish_struct (tree t, tree fieldlist, t
break;
if (x == 0)
- pedwarn ("%s has no %s",
- TREE_CODE (t) == UNION_TYPE ? _("union") : _("struct"),
- fieldlist ? _("named members") : _("members"));
+ {
+ if (TREE_CODE (t) == UNION_TYPE)
+ {
+ if (fieldlist)
+ pedwarn ("union has no named members");
+ else
+ pedwarn ("union has no members");
+ }
+ else
+ {
+ if (fieldlist)
+ pedwarn ("struct has no named members");
+ else
+ pedwarn ("struct has no members");
+ }
+ }
}
/* Install struct as DECL_CONTEXT of each field decl.