This is the mail archive of the
mailing list for the GCC project.
Re: C++ PATCH for c++/88373, wrong parse error with ~
- From: Jason Merrill <jason at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 6 Dec 2018 14:39:30 -0500
- Subject: Re: C++ PATCH for c++/88373, wrong parse error with ~
- References: <20181206163316.GM21364@redhat.com>
On 12/6/18 11:33 AM, Marek Polacek wrote:
This patch fixes a bogus parse error with ~ in a template-argument-list. We have
S<int, ~value <int>>
and cp_parser_template_argument just tries to parse each argument as a type,
id-expression, etc to see what sticks. When it sees ~value, it tries to parse
it using cp_parser_class_name (because of the ~), which ends up calling
cp_parser_lookup_name, looking for "value", but finds nothing. Since it's an
unqualified-id followed by <, we treat "~value<int>" as a template name
function. It isn't followed by "(args)", so we simulate parse error. As a
consequence of this error, the parsing of the outermost template-id S fails.
The problem is that when we're looking up the name in cp_parser_class_name,
tag_type is typename_type, which means bindings that do not refer to types
are ignored, so the variable template "value" isn't found and we're toast.
Bootstrapped/regtested on x86_64-linux, ok for trunk?