On Fri, May 18, 2018 at 4:41 AM, Paolo Carlini <paolo.carl...@oracle.com> wrote:
> Hi,
>
>>> On 18/05/2018 01:21, Jason Merrill wrote:
>>>>
>>>> On Thu, May 17, 2018 at 5:54 PM, Paolo Carlini
>>>> <paolo.carl...@oracle.com> wrote:
>>>>>
>>>>> On 17/05/2018 16:58, Jason Merrill wrote:
>>>>>>
>>>>>> On Thu, May 17, 2018 at 10:27 AM, Paolo Carlini
>>>>>> <paolo.carl...@oracle.com> wrote:
>>>>>>>
>>>>>>> PS: maybe better using function_declarator_p?
>>>>>>
>>>>>> I think so, yes.  The relevant rule seems to be "The declarator shall
>>>>>> not specify a function or an array.", so let's check for arrays, too.
>>>>>
>>>>> Agreed. I had the amended patch ready when I noticed (again) that it
>>>>> wasn't
>>>>> addressing another related class of issues which involves declarators
>>>>> not
>>>>> followed by initializers. Thus I tried to fix those too, and the below
>>>>> which
>>>>> moves the check up appears to work fine, passes testing, etc. Are there
>>>>> any
>>>>> risks that an erroneous function / array as declarator is in fact a
>>>>> well
>>>>> formed expression?!?
>>>>
>>>> That doesn't matter; if it parses as a declarator, it's a declarator,
>>>> even if it's an ill-formed declarator.  But...
>>>>
>>>> +      bool decl_p = cp_parser_parse_definitely (parser);
>>>> +      if (!cp_parser_check_condition_declarator (parser, declarator,
>>>> loc))
>>>> +        return error_mark_node;
>>>>
>>>> ...if cp_parser_parse_definitely returns false, parsing as a
>>>> declarator failed, so we shouldn't look at "declarator".
>
> What I'm attaching below isn't affected by this problem: I moved the check
> further up - *before* maybe calling cp_parser_simulated_error because an
> initializer isn't in sight - and is carried out only when
> !cp_parser_error_occurred, thus cp_parser_declarator succeeded .
> cp_parser_commit_to_tentative_parse is called when the check fails.
> Bootstrapped and tested on x86_64-linux.

I had in mind moving the call to cp_parser_check_condition_declarator
into the block controlled by cp_parser_parse_definitely; this is a
semantic check that should follow the syntactic checks.  If there's no
initializer, it doesn't parse as a condition declaration, so we don't
want to complain about it being a semantically invalid condition
declaration.

Jason

Reply via email to