[PATCH C] Fix pr44517
Shujing Zhao
pearly.zhao@oracle.com
Wed Jun 23 09:17:00 GMT 2010
On 06/22/2010 08:55 PM, Joseph S. Myers wrote:
> On Tue, 22 Jun 2010, Shujing Zhao wrote:
>
>> Hi,
>>
>> This patch tries to improve diagnostic for wrong type name in function
>> declaration. It also changes the algorithm of function
>> c_parser_parms_list_declarator. If one of parameter declaration is wrong,
>> c_parser_parms_list_declarator would return NULL, not an empty parameter
>> information struct. A test case is added to test this change.
>
> You are changing the semantics of the variable good_parm from meaning
> "there was at least one good parameter" to "there were no bad parameters".
> Now, such a change should be accompanied by a change of name (e.g. to
> bad_parm, also reversing the sense of the variable).
>
> There was a previous invariant that get_pending_sizes would be called
> after any parameters were parsed, either directly or via get_parm_info
> because good_parm would be set, and with this patch, this invariant is no
> longer maintained. This is unsafe; you need to run this cleanup, whatever
> you then return from c_parser_parms_list_declarator. Consider for example
> the testcase:
>
> void foo(int n, int a[n], pid_t x);
> void bar() {}
>
> (related to gcc.dg/noncompile/pr35444-*.c). With your patch, this
> testcase (which should be added to the next revision of the patch) gets an
> ICE, because you lost the call to get_pending_sizes via get_parm_info.
>
You are right! Yes, If append the above test case to the end of pr44517.c, it
gets an ICE.
The above problem is fixed at the updated patch and the test case is moved to
the directory gcc.dg/noncompile/.
>> + error ("unknown type name %qE", token->value);
>
> I don't think %qE is appropriate here if the token is not an identifier.
>
Yes. But the problem is that token->id_kind is C_ID_ID and token->value is
IDENTIFIER_NODE. At function c_lex_one_token, the token->id_kind is always be
set to C_ID_ID if it is not the other identifier. Look at enum c_id_kind,
C_ID_ID is "an ordinary identifier" and there is an "not an identifier"
C_ID_NONE, but it never be really set. If token is CPP_NAME, and it was not
declared as some type name, the token->id_kind should be set C_ID_NONE. But
where should C_ID_ID be set?
I think that is the problem of c_lex_one_token, not the message format. I can't
give a solution for that issue now. Does this patch can be committed firstly?
Retested on i686-pc-linux-gnu. 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/20100623/bb7f6c30/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr44517.patch
Type: text/x-patch
Size: 4674 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100623/bb7f6c30/attachment.bin>
More information about the Gcc-patches
mailing list