aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@markmitchell.com>1998-10-16 13:24:28 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1998-10-16 13:24:28 +0000
commit588c2d1c2f7303efadc5159cab5af58d78d1c405 (patch)
tree127e237c9bd7170c301d5c18d276709ebadb7d04 /gcc
parentcc4824564d972ee9f170612d1ab637a37b8ee683 (diff)
downloadgcc-588c2d1c2f7303efadc5159cab5af58d78d1c405.zip
gcc-588c2d1c2f7303efadc5159cab5af58d78d1c405.tar.gz
gcc-588c2d1c2f7303efadc5159cab5af58d78d1c405.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c29
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/defarg5.C24
3 files changed, 50 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 317161b..4fa45af 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c3e2d2e..852634c 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 0000000..6a68bad
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg5.C
@@ -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;
+};