pt.c (for_each_template_parm): Don't examine uninstantiated default arguments.

* pt.c (for_each_template_parm): Don't examine uninstantiated
	default arguments.

From-SVN: r23137
This commit is contained in:
Mark Mitchell 1998-10-16 13:24:28 +00:00 committed by Mark Mitchell
parent cc4824564d
commit 588c2d1c2f
3 changed files with 50 additions and 8 deletions

View File

@ -1,3 +1,8 @@
1998-10-16 Mark Mitchell <mark@markmitchell.com>
* pt.c (for_each_template_parm): Don't examine uninstantiated
default arguments.
1998-10-16 Dave Brolley <brolley@cygnus.com>
* lex.c (real_yylex): Fix unaligned access of wchar_t.

View File

@ -3766,10 +3766,29 @@ for_each_template_parm (t, fn, data)
return for_each_template_parm (TREE_VALUE
(TYPE_TEMPLATE_INFO (t)),
fn, data);
case FUNCTION_TYPE:
if (for_each_template_parm (TYPE_ARG_TYPES (t), fn, data))
case METHOD_TYPE:
if (for_each_template_parm (TYPE_METHOD_BASETYPE (t), fn, data))
return 1;
/* Fall through. */
case FUNCTION_TYPE:
/* Check the parameter types. Since default arguments are not
instantiated until they are needed, the TYPE_ARG_TYPES may
contain expressions that involve template parameters. But,
no-one should be looking at them yet. And, once they're
instantiated, they don't contain template parameters, so
there's no point in looking at them then, either. */
{
tree parm;
for (parm = TYPE_ARG_TYPES (t); parm; parm = TREE_CHAIN (parm))
if (for_each_template_parm (TREE_VALUE (parm), fn, data))
return 1;
}
/* Check the return type, too. */
return for_each_template_parm (TREE_TYPE (t), fn, data);
case ARRAY_TYPE:
if (for_each_template_parm (TYPE_DOMAIN (t), fn, data))
return 1;
@ -3778,12 +3797,6 @@ for_each_template_parm (t, fn, data)
if (for_each_template_parm (TYPE_OFFSET_BASETYPE (t), fn, data))
return 1;
return for_each_template_parm (TREE_TYPE (t), fn, data);
case METHOD_TYPE:
if (for_each_template_parm (TYPE_METHOD_BASETYPE (t), fn, data))
return 1;
if (for_each_template_parm (TYPE_ARG_TYPES (t), fn, data))
return 1;
return for_each_template_parm (TREE_TYPE (t), fn, data);
/* decl nodes */
case TYPE_DECL:

View File

@ -0,0 +1,24 @@
// Build don't link:
template <int dim>
class Point {
public:
Point (Point<dim> &);
Point<dim> & operator = (Point<dim> &);
};
template <int dim>
class bar{
public:
void foo (Point<dim> p = Point<dim>());
};
template <>
void bar<2>::foo (Point<2> p) {
const int dim = 2;
Point<dim> q = p;
};