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: [C++ PATCH] [PR14028] Parser accepts invalid unbalanced bracket (regression 3.4/3.5)


Giovanni Bajo wrote:

Hello,

the parser accepts invalid code such as:
----------------------------------------------------------
template <int> struct A {};
template <typename TP> class B : public A<4  {};  // missing bracket!
----------------------------------------------------------

This happens because the check is done by cp_parser_require, which does not
emit an error during tentative parsing. The argument list is not invalidated by
this, and a CPP_TEMPLATE_ID is created, so that subsequent (non-tentative)
parsings fail to diagnose the problem. Fixed by forcing a hard error.

Tested on i686-pc-linux-gnu, OK for mainline and 3.4?


I'm a little nervous about this because if it turned out that this was something other than a template-id, then issuing the error would be wrong. But, it looks like that can't happen.

So, OK for mainline and GCC 3.4.

--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com



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