aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/pt.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2007-09-24 16:54:34 -0400
committerJason Merrill <jason@gcc.gnu.org>2007-09-24 16:54:34 -0400
commit7a20d68989dac61d98b12b5d32404f04021d211f (patch)
treeb77c7efb5fdcf917f41b024686f780683d8ff1ff /gcc/cp/pt.c
parent7b7bdf67e021444850352aebe14b288aca4c29c7 (diff)
downloadgcc-7a20d68989dac61d98b12b5d32404f04021d211f.zip
gcc-7a20d68989dac61d98b12b5d32404f04021d211f.tar.gz
gcc-7a20d68989dac61d98b12b5d32404f04021d211f.tar.bz2
re PR c++/33239 (internal compiler error in instantiate_class_template, at cp/pt.c:5666)
PR c++/33239 * pt.c (resolve_typename_type): Don't look things up in the original template if it would mean losing template arguments. From-SVN: r128725
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r--gcc/cp/pt.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c9ec370..5b07c70 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -15732,9 +15732,16 @@ resolve_typename_type (tree type, bool only_current_p)
to look inside it. */
if (only_current_p && !currently_open_class (scope))
return type;
- /* If SCOPE is a partial instantiation, it will not have a valid
- TYPE_FIELDS list, so use the original template. */
- scope = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope);
+ /* If SCOPE isn't the template itself, it will not have a valid
+ TYPE_FIELDS list. */
+ if (same_type_p (scope, CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope)))
+ /* scope is either the template itself or a compatible instantiation
+ like X<T>, so look up the name in the original template. */
+ scope = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope);
+ else
+ /* scope is a partial instantiation, so we can't do the lookup or we
+ will lose the template arguments. */
+ return type;
/* Enter the SCOPE so that name lookup will be resolved as if we
were in the class definition. In particular, SCOPE will no
longer be considered a dependent type. */