re PR c++/38638 (ICE superfluous 'typename')

gcc/cp/

2009-03-27  Andrew Pinski  <andrew_pinski@playstation.sony.com>

	PR c++/38638
	* 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.

gcc/testsuite/

2009-03-27  Andrew Pinski  <andrew_pinski@playstation.sony.com>

	PR c++/38638
	* g++.dg/template/typename17.C: New testcase.
	* g++.dg/template/typename18.C: New testcase.

From-SVN: r145107
This commit is contained in:
Andrew Pinski 2009-03-27 13:36:33 +00:00 committed by H.J. Lu
parent b0957daf07
commit 8ec0d73b34
5 changed files with 42 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2009-03-27 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR c++/38638
* 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.
2009-03-27 Simon Martin <simartin@users.sourceforge.net>
PR c++/37647

View File

@ -11588,7 +11588,11 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
type = make_typename_type (parser->scope, decl,
typename_type,
/*complain=*/tf_error);
else
/* If the `typename' keyword is in effect and DECL is not a type
decl. Then type is non existant. */
else if (tag_type == typename_type && TREE_CODE (decl) != TYPE_DECL)
type = NULL_TREE;
else
type = TREE_TYPE (decl);
}

View File

@ -1,3 +1,9 @@
2009-03-27 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR c++/38638
* g++.dg/template/typename17.C: New testcase.
* g++.dg/template/typename18.C: New testcase.
2009-03-27 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR c++/36799

View File

@ -0,0 +1,10 @@
// { dg-do compile }
// This should fail as A::foo<0> is not a typename at all.
struct A
{
template<int> void foo(int i)
{
typename A::foo<0>(i1); // { dg-error "" }
}
};

View File

@ -0,0 +1,14 @@
// { dg-do compile }
// These typename should work as they are types.
struct A
{
typedef int a;
template <int>
struct f {};
template<int> void foo(int i)
{
typename A::a(i1);
typename A::f<0>(i2);
}
};