This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C PATCH] warn for empty struct -Wc++-compat


On Tue, 11 Nov 2014, Marek Polacek wrote:

@@ -7506,12 +7509,19 @@
 /* Finish up struct info used by -Wc++-compat.  */

 static void
-warn_cxx_compat_finish_struct (tree fieldlist)
+warn_cxx_compat_finish_struct (tree fieldlist, location_t record_loc)
 {
   unsigned int ix;
   tree x;
   struct c_binding *b;

+  if (fieldlist == NULL_TREE)
+    {
+      warning_at (record_loc, OPT_Wc___compat,
+		  "empty %s has size 0 in C, 1 in C++",
+		  (struct_parse_info->code == RECORD_TYPE) ? "struct" : "union");
+    }
+

I think this won't work well wrt translations, so you need to have
an if here.  See the pedwarns at the beginning of finish_struct.

Do keywords like struct/union really require translation?

--
Marc Glisse


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]