[PATCH] Fix C++/38638 ICE superfluous 'typename'

Andrew Pinski pinskia@gmail.com
Thu Jan 1 02:37:00 GMT 2009


Hi,
  The problem here is that the parser was not checking if we were in
typename mode that we either got back a TYPE_DECL or a
TEMPLATE_ID_EXPR.  This would either allow the code (in much older
versions of GCC) or cause an ICE when seeing if the type is a const
type or not as the type would be an "unknown type".  This fixes the
problem by adding in the case if we don't have a TYPE_DECL or a
TEMPLATE_ID_EXPR, set the type to NULL so we will error out about this
not being a type later on.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
* parser.c (cp_parser_elaborated_type_specifier): If we have a
typename tag and don't have either a TYPE_DECL or a TEMPLATE_ID_EXPR,
set the type to NULL.

* g++.dg/template/typename15.C: New testcase.
* g++.dg/template/typename16.C: New testcase.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fix38638.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090101/cd59f43f/attachment.txt>


More information about the Gcc-patches mailing list