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] PR c/20385: more detection of unknown type names


>> - ? ? ? ? ?/* If we cannot accept a type, and the next token must start one,
>> - ? ? ? ? ?exit. ?Do the same if we already have seen a tagged definition,
>> - ? ? ? ? ?since it would be an error anyway and likely the user has simply
>> - ? ? ? ? ?forgotten a semicolon. ?*/
>> - ? ? ? ? ?if ((!typespec_ok || specs->typespec_kind == ctsk_tagdef)
>> - ? ? ? ? ? && c_parser_next_token_starts_typename (parser))
>> - ? ? ? ? ? ?break;
>> + ? ? ? ? ?la = nonabstract_decl ? cla_nonabstract_decl : cla_prefer_type;
>> + ? ? ? ? ?if (c_parser_next_tokens_start_typename (parser, la))
>> + ? ? ? ? ? ?{
>> + ? ? ? ? ? ? ?/* We cannot accept a type, and the next token must start one;
>> + ? ? ? ? ? ? ? ? exit. ?Do the same if we already have seen a tagged definition,
>> + ? ? ? ? ? ? ? ? since it would be an error anyway and likely the user has simply
>> + ? ? ? ? ? ? ? ? forgotten a semicolon. ?*/
>> + ? ? ? ? ? ? ?if (!typespec_ok || specs->typespec_kind == ctsk_tagdef)
>> + ? ? ? ? ? ? ? ?break;
>
> As far as I can see, this rewording of the comment is incorrect; inside
> the outer if, we don't yet know that "We cannot accept a type", that's the
> first condition of the inner if. ?I think the original wording would still
> have been correct here.

Right.

> Also, I'm concerned about the interaction of the new parameter with the
> !typespec_ok case. ?Logically, I don't think the new parameter should
> matter at all in that case; if type names aren't valid (as in qualifiers
> in pointer and array declarators), this function shouldn't attempt to
> guess what undeclared identifiers might be, it should just return for
> them.

I agree it is better to use cla_prefer_id if !typespec_ok.

Thanks for the review!

Paolo


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