[PATCH, C] PR18249

Shujing Zhao pearly.zhao@oracle.com
Fri May 21 11:19:00 GMT 2010


On 05/20/2010 11:59 PM, Joseph S. Myers wrote:
> On Thu, 20 May 2010, Shujing Zhao wrote:
> 
>> +      switch (desired)
>> +	{
>> +	  case NLE_NULL:
>> +	    break;
> 
> As I understand it, the previous code would have crashed in the cases that 
> now pass NLE_NULL - so those cases should never reach this part of the 
> function, and a call to gcc_unreachable () would be better than silently 
> continuing.
Yes, you are right. I just found if (decl != error_mark_node), the desired would 
never be NULL.
>> +	      case CPP_COLON:
>> +		if (strcmp (token_desc, "%<:%> or %<::%>") == 0)
>> +		  cp_parser_error (parser, "expected %<:%> or %<::%>");
>> +		else
>> +		  cp_parser_error (parser, "expected %<:%>");
>> +		break;
> 
> I don't like this approach of checking for magic strings in a description 
> parameter.  Better to change that parameter to an enum.  In the generic 
> cases
Ok, I originally thought an enum can maybe be avoided :). To clear the messages, 
An enum required_token is added this time. A new function 
cp_parser_required_error is added to handle the required message.

> if you use an explicit cp_parser_error call for each case then you can 
> keep using %< and %> and so get consistent English quotes.  (Actually, you 
> could get consistent quotes anyway by using %%< and %%> instead of '' in 
> the asprintf format string, as the result of asprintf gets passed through 
> the GCC format interpretation by cp_parser_error.  But the double 
> interpretation isn't going to be obvious to translators, which itself is a 
> reason to avoid building up format strings with asprintf.)
Thanks

Tested on i686-pc-linux-gnu with no regression. Is it ok?

Thanks
Pearly


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ChangeLog
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100521/1d2b4854/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 18249.patch
Type: text/x-patch
Size: 93391 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100521/1d2b4854/attachment.bin>


More information about the Gcc-patches mailing list