diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 317161bf1cc..4fa45af5663 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1998-10-16 Mark Mitchell + + * pt.c (for_each_template_parm): Don't examine uninstantiated + default arguments. + 1998-10-16 Dave Brolley * lex.c (real_yylex): Fix unaligned access of wchar_t. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c3e2d2ebdc2..852634c622a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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: diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg5.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg5.C new file mode 100644 index 00000000000..6a68bad8251 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg5.C @@ -0,0 +1,24 @@ +// Build don't link: + +template +class Point { + public: + Point (Point &); + Point & operator = (Point &); +}; + + + +template +class bar{ + public: + void foo (Point p = Point()); +}; + + + +template <> +void bar<2>::foo (Point<2> p) { + const int dim = 2; + Point q = p; +};