re PR c++/15064 (typeid of template parameter gives ICE)

PR c++/15064
	* parser.c (cp_parser_postfix_expression): typeid operator cannot be
	used in integral constant expressions.

	PR c++/15064
	* g++.dg/template/crash18.C: New test.

From-SVN: r81088
This commit is contained in:
Giovanni Bajo 2004-04-23 12:57:19 +00:00
parent d0fd134432
commit 4424e0da57
4 changed files with 28 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2004-04-23 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/15064
* parser.c (cp_parser_postfix_expression): typeid operator cannot be
used in integral constant expressions.
2004-04-22 Mark Mitchell <mark@codesourcery.com>
* init.c (build_aggr_init): Fix accidental use of C99 construct in

View File

@ -3594,7 +3594,10 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p)
/* Look for the `)' token. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
}
/* `typeid' may not appear in an integral constant expression. */
if (cp_parser_non_integral_constant_expression(parser,
"`typeid' operator"))
return error_mark_node;
/* Restore the saved message. */
parser->type_definition_forbidden_message = saved_message;
}

View File

@ -1,3 +1,8 @@
2004-04-23 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/15064
* g++.dg/template/crash18.C: New test.
2004-04-22 Mark Mitchell <mark@codesourcery.com>
* g++.dg/ext/complit3.C: New test.

View File

@ -0,0 +1,13 @@
// { dg-do compile }
// Contributed by: <leif dot lonnblad at thep dot lu dot se>
// PR c++/15064: typeid does not form an integral constant expression
#include <typeinfo>
template <typename T>
void dummy() {
const std::type_info& t = typeid(T);
const std::type_info& t2 = typeid(float);
}
template void dummy<int>(void);