This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: Fix 11347
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Mark Mitchell <mitchell at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 30 Jul 2003 17:26:16 +0100
- Subject: [C++ PATCH]: Fix 11347
- Organization: Codesourcery LLC
Hi,
this fixes 11347 an ICE when we attempt to lookup a name inside a
partial instantiation.
When tsubsting the definition of a templated member because we're
instantiating the template it is a member of, we are really processing
a template decl.
booted & tested on i686-pc-linux-gnu, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2003-07-30 Nathan Sidwell <nathan@codesourcery.com>
PR c++/11347
* pt.c (instantiate_class_template): Increment
processing_template_decl around the tsubst of a template member
class.
(tsubst_qualified_id): Assert we do not have a dependent scope.
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.742
diff -c -3 -p -r1.742 pt.c
*** cp/pt.c 29 Jul 2003 11:16:48 -0000 1.742
--- cp/pt.c 29 Jul 2003 13:50:30 -0000
*************** instantiate_class_template (tree type)
*** 5318,5324 ****
--- 5318,5328 ----
restore these. */
input_location = DECL_SOURCE_LOCATION (t);
+ if (TREE_CODE (t) == TEMPLATE_DECL)
+ processing_template_decl++;
r = tsubst (t, args, tf_error | tf_warning, NULL_TREE);
+ if (TREE_CODE (t) == TEMPLATE_DECL)
+ processing_template_decl--;
if (TREE_CODE (r) == VAR_DECL)
{
tree init;
*************** tsubst_qualified_id (tree qualified_id,
*** 7146,7167 ****
else
expr = name;
! /* This case can occur while determining which of two templates is
! the more specialized. After performing argument deduction, we
! check that no invalid types are created. During that phase, we
! may seem uninstantiated template parameters. */
! if (TREE_CODE (scope) == BOUND_TEMPLATE_TEMPLATE_PARM)
! {
! if (is_template)
! expr = lookup_template_function (expr, template_args);
! return build_nt (SCOPE_REF, scope, expr);
! }
!
if (!BASELINK_P (name) && !DECL_P (expr))
expr = lookup_qualified_name (scope, expr, /*is_type_p=*/0, false);
if (DECL_P (expr))
! check_accessibility_of_qualified_id (expr,
! /*object_type=*/NULL_TREE,
scope);
/* Remember that there was a reference to this entity. */
--- 7147,7159 ----
else
expr = name;
! my_friendly_assert (!dependent_type_p (scope), 20030729);
!
if (!BASELINK_P (name) && !DECL_P (expr))
expr = lookup_qualified_name (scope, expr, /*is_type_p=*/0, false);
+
if (DECL_P (expr))
! check_accessibility_of_qualified_id (expr, /*object_type=*/NULL_TREE,
scope);
/* Remember that there was a reference to this entity. */
// { dg-do compile }
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 30 Jul 2003 <nathan@codesourcery.com>
// PR 11347. ICE in tsubst
template <class T> struct T1 {
enum {N};
};
template<class T> struct T2 {
template <class S, bool Z = T1<S>::N + 1> struct B {};
struct C {};
};
T2<int> t;
T2<int>::B<int> s;