aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mmitchell@usa.net>1998-04-26 13:36:02 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1998-04-26 13:36:02 +0000
commita2b60a0ea2f0741a97fa8ec0e777ed134ce3dc7b (patch)
treec56ff3ea37e9f7771b4a2bf732cb7bbe2096b295
parent42da2fd81b78cbd3cf2951b3d35c01d8693977ac (diff)
downloadgcc-a2b60a0ea2f0741a97fa8ec0e777ed134ce3dc7b.zip
gcc-a2b60a0ea2f0741a97fa8ec0e777ed134ce3dc7b.tar.gz
gcc-a2b60a0ea2f0741a97fa8ec0e777ed134ce3dc7b.tar.bz2
pt.c (mabybe_get_template_decl_from_type_decl): New function.
* pt.c (mabybe_get_template_decl_from_type_decl): New function. (lookup_template_class): Use it. From-SVN: r19414
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/pt.c26
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/memclass8.C11
3 files changed, 37 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 323d0e4..a6bd63f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -3,6 +3,9 @@ Sun Apr 26 12:10:18 1998 Mark Mitchell <mmitchell@usa.net>
* pt.c (check_explicit_specialization): Handle overloaded
constructors correctly.
+ * pt.c (mabybe_get_template_decl_from_type_decl): New function.
+ (lookup_template_class): Use it.
+
Thu Apr 23 21:19:06 1998 Jason Merrill <jason@yorick.cygnus.com>
* cp-tree.def: Add WRAPPER. USER_CONV now only has two ops.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 01868c5..a0c4e6b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -102,6 +102,7 @@ static int mark_template_parm PROTO((tree, void *));
static tree tsubst_friend_function PROTO((tree, tree));
static tree get_bindings_real PROTO((tree, tree, tree, int));
static int template_decl_level PROTO((tree));
+static tree maybe_get_template_decl_from_type_decl PROTO((tree));
/* Do any processing required when DECL (a member template declaration
using TEMPLATE_PARAMETERS as its innermost parameter list) is
@@ -2695,6 +2696,23 @@ lookup_template_function (fns, arglist)
fns, arglist);
}
+/* Within the scope of a template class S<T>, the name S gets bound
+ (in build_self_reference) to a TYPE_DECL for the class, not a
+ TEMPLATE_DECL. If DECL is a TYPE_DECL for current_class_type,
+ or one of its enclosing classes, and that type is a template,
+ return the associated TEMPLATE_DECL. Otherwise, the original
+ DECL is returned. */
+
+tree
+maybe_get_template_decl_from_type_decl (decl)
+ tree decl;
+{
+ return (decl != NULL_TREE
+ && TREE_CODE (decl) == TYPE_DECL
+ && DECL_ARTIFICIAL (decl)
+ && CLASSTYPE_TEMPLATE_INFO (TREE_TYPE (decl)))
+ ? CLASSTYPE_TI_TEMPLATE (TREE_TYPE (decl)) : decl;
+}
/* Given an IDENTIFIER_NODE (type TEMPLATE_DECL) and a chain of
parameters, find the desired type.
@@ -2727,9 +2745,11 @@ lookup_template_class (d1, arglist, in_decl, context)
template = IDENTIFIER_LOCAL_VALUE (d1);
else
{
- template = IDENTIFIER_NAMESPACE_VALUE (d1); /* XXX */
- if (! template)
- template = IDENTIFIER_CLASS_VALUE (d1);
+ template =
+ maybe_get_template_decl_from_type_decl
+ (IDENTIFIER_CLASS_VALUE (d1));
+ if (template == NULL_TREE)
+ template = IDENTIFIER_NAMESPACE_VALUE (d1);
}
if (template)
context = DECL_CONTEXT (template);
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass8.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass8.C
new file mode 100644
index 0000000..c0bf0cd
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass8.C
@@ -0,0 +1,11 @@
+// Build don't link:
+
+template <class T>
+class S
+{
+ template <class U>
+ class S2 {
+ S2(const S2<U>& s2u) {}
+ };
+};
+