This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Revision 2: utf-16 and utf-32 support in C and C++
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Kris Van Hees <kris dot van dot hees at oracle dot com>
- Cc: Jason Merrill <jason at redhat dot com>, Andrew Pinski <pinskia at gmail dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 10 Apr 2008 16:51:24 +0000 (UTC)
- Subject: Re: [PATCH] Revision 2: utf-16 and utf-32 support in C and C++
- References: <20080331185400.GB3167@oracle.com> <47F691F4.1090700@redhat.com> <20080405124416.GB16535@oracle.com>
On Sat, 5 Apr 2008, Kris Van Hees wrote:
> >> + /* 'L', 'u' or 'U' may introduce wide characters or strings. */
> >> + if (c == 'L'
> >> + || (CPP_OPTION (pfile, c99)
> >> + && (CPP_OPTION (pfile, cplusplus) || !CPP_OPTION (pfile, std))))
> >
> > This test seems wrong.
>
> I do believe it is correct, though perhaps there is a better way to encode the
> same effect in a less confusing way. It is correct given the following table
> of language flags (from libcpp/init.c):
>
> static const struct lang_flags lang_defaults[] =
> { /* c99 c++ xnum xid std // digr */
> /* GNUC89 */ { 0, 0, 1, 0, 0, 1, 1 },
> /* GNUC99 */ { 1, 0, 1, 0, 0, 1, 1 },
> /* STDC89 */ { 0, 0, 0, 0, 1, 0, 0 },
> /* STDC94 */ { 0, 0, 0, 0, 1, 0, 1 },
> /* STDC99 */ { 1, 0, 1, 0, 1, 1, 1 },
> /* GNUCXX */ { 0, 1, 1, 0, 0, 1, 1 },
> /* CXX98 */ { 0, 1, 1, 0, 1, 1, 1 },
> /* GNUCXX0X */ { 1, 1, 1, 0, 0, 1, 1 },
> /* CXX0X */ { 1, 1, 1, 0, 1, 1, 1 },
> /* ASM */ { 0, 0, 1, 0, 0, 1, 0 }
>
> The logic (c99 && (c++ || !std)) is only true for: GNUC99, GNUCXX0X, CXX0X.
>
> Would it be better to use something like:
>
> if (c == 'L' ||
> CPP_OPTION (pfile, lang) == CLK_GNUC99 ||
> CPP_OPTION (pfile, lang) == CLK_GNUCXX0X ||
> CPP_OPTION (pfile, lang) == CLK_CXX0X)
It would be better to add a new field to struct lang_flags and an
associated field in cpp_options to indicate explicitly whether [uU]['"] is
supported, rather than computing it by a combination of other fields.
--
Joseph S. Myers
joseph@codesourcery.com