This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C PATCH] warn for empty struct -Wc++-compat
- From: Marek Polacek <polacek at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Prathamesh Kulkarni <bilbotheelffriend at gmail dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Tue, 11 Nov 2014 12:36:49 +0100
- Subject: Re: [C PATCH] warn for empty struct -Wc++-compat
- Authentication-results: sourceware.org; auth=none
- References: <CAJXstsAQ0GLXs7rYJeZTY1_ccgS84HXkU+X7pKKNfQPmh8TGHw at mail dot gmail dot com> <20141110220517 dot GF10852 at redhat dot com> <CAJXstsD3b4Ma7q1VpmOcDaVi5G5Tijk0O2S0ex6yCXrdiDPvWA at mail dot gmail dot com> <20141111110023 dot GG10852 at redhat dot com> <alpine dot DEB dot 2 dot 11 dot 1411111211260 dot 1640 at laptop-mg dot saclay dot inria dot fr>
On Tue, Nov 11, 2014 at 12:13:32PM +0100, Marc Glisse wrote:
> 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?
C keywords don't require translation, but you always need to have
complete sentences in diagnostics so I better pointed it out. Joseph
would know better than me though.
Marek