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: [PATCH] Revision 2: utf-16 and utf-32 support in C and C++


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


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