aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/typeck.c
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2010-03-25 22:08:33 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2010-03-25 23:08:33 +0100
commit58f5f6b43067ab86fd26efdf13e3c0929dadb8f4 (patch)
tree696a213308b6552c9c3faed80c9aff8e772b1386 /gcc/cp/typeck.c
parent9b7e6950f5119d62c5afb8ea914c7894c304050a (diff)
downloadgcc-58f5f6b43067ab86fd26efdf13e3c0929dadb8f4.zip
gcc-58f5f6b43067ab86fd26efdf13e3c0929dadb8f4.tar.gz
gcc-58f5f6b43067ab86fd26efdf13e3c0929dadb8f4.tar.bz2
Fix candidate for PR c++/43206
gcc/cp/ChangeLog: PR c++/43206 * cp-tree.h (get_template_parms_at_level): Declare ... * pt.c (get_template_parms_at_level): ... new function. * typeck.c (get_template_parms_of_dependent_type): If a template type parm's DECL_CONTEXT isn't yet set, get its siblings from current_template_parms. Use get_template_parms_at_level. Remove useless test. (incompatible_dependent_types_p): If we get empty parms from just one of the template type parms we are comparing then the template parms are incompatible. gcc/testsuite/ChangeLog: PR c++/43206 * g++.dg/template/typedef30.C: New test case. From-SVN: r157730
Diffstat (limited to 'gcc/cp/typeck.c')
-rw-r--r--gcc/cp/typeck.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index b9ef78f..a4c64ea 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1113,9 +1113,17 @@ get_template_parms_of_dependent_type (tree t)
/* If T1 is a typedef or whatever has a template info associated
to its context, get the template parameters from that context. */
else if (typedef_variant_p (t)
- && DECL_CONTEXT (TYPE_NAME (t))
- && !NAMESPACE_SCOPE_P (TYPE_NAME (t)))
+ && !NAMESPACE_SCOPE_P (TYPE_NAME (t)))
tinfo = get_template_info (DECL_CONTEXT (TYPE_NAME (t)));
+ else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM
+ && DECL_CONTEXT (TYPE_NAME (t)) == NULL_TREE)
+ /* We have not yet created the DECL_TEMPLATE this
+ template type parm belongs to. It probably means
+ that we are in the middle of parsing the template parameters
+ of a template, and T is one of the parameters we have parsed.
+ Let's return the list of template parms we have parsed so far. */
+ return get_template_parms_at_level (current_template_parms,
+ TEMPLATE_TYPE_LEVEL (t));
else if (TYPE_CONTEXT (t)
&& !NAMESPACE_SCOPE_P (t))
tinfo = get_template_info (TYPE_CONTEXT (t));
@@ -1170,6 +1178,17 @@ incompatible_dependent_types_p (tree t1, tree t2)
tparms1 = get_template_parms_of_dependent_type (t1);
tparms2 = get_template_parms_of_dependent_type (t2);
+ /* If T2 is a template type parm and if we could not get the template
+ parms it belongs to, that means we have not finished parsing the
+ full set of template parameters of the template declaration it
+ belongs to yet. If we could get the template parms T1 belongs to,
+ that mostly means T1 and T2 belongs to templates that are
+ different and incompatible. */
+ if (TREE_CODE (t1) == TEMPLATE_TYPE_PARM
+ && (tparms1 == NULL_TREE || tparms2 == NULL_TREE)
+ && tparms1 != tparms2)
+ return true;
+
if (tparms1 == NULL_TREE
|| tparms2 == NULL_TREE
|| tparms1 == tparms2)