This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: Fix 23984
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 14 Oct 2005 17:01:41 +0100
- Subject: [C++ PATCH]: Fix 23984
I've installed this patch to fix 23984, an ICE on 4.0. We don't properly manage
function parameter scope in C++.
built & tested on i686-pc-linux-gnu.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2005-10-14 Nathan Sidwell <nathan@codesourcery.com>
PR c++/22603
Backport part of
2005-03-14 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* name-lookup.c (pushtag): Skip template parameter scope when
scope is ts_global. Don't push tag into template parameter
scope.
Index: cp/name-lookup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.c,v
retrieving revision 1.109.4.9
diff -c -3 -p -r1.109.4.9 name-lookup.c
*** cp/name-lookup.c 9 Sep 2005 21:05:52 -0000 1.109.4.9
--- cp/name-lookup.c 14 Oct 2005 13:05:46 -0000
*************** pushtag (tree name, tree type, tag_scope
*** 4582,4591 ****
/* Neither are the scopes used to hold template parameters
for an explicit specialization. For an ordinary template
declaration, these scopes are not scopes from the point of
! view of the language -- but we need a place to stash
! things that will go in the containing namespace when the
! template is instantiated. */
! || (b->kind == sk_template_parms && b->explicit_spec_p)
|| (b->kind == sk_class
&& (scope != ts_current
/* We may be defining a new type in the initializer
--- 4582,4590 ----
/* Neither are the scopes used to hold template parameters
for an explicit specialization. For an ordinary template
declaration, these scopes are not scopes from the point of
! view of the language. */
! || (b->kind == sk_template_parms
! && (b->explicit_spec_p || scope == ts_global))
|| (b->kind == sk_class
&& (scope != ts_current
/* We may be defining a new type in the initializer
*************** pushtag (tree name, tree type, tag_scope
*** 4658,4664 ****
else
pushdecl_class_level (decl);
}
! else
decl = pushdecl_with_scope (decl, b);
/* FIXME what if it gets a name from typedef? */
--- 4657,4663 ----
else
pushdecl_class_level (decl);
}
! else if (b->kind != sk_template_parms)
decl = pushdecl_with_scope (decl, b);
/* FIXME what if it gets a name from typedef? */
// { dg-do run }
// Copyright (C) 2005 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 13 Oct 2005 <nathan@codesourcery.com>
// PR 23984:ICE
// Origin: Andrew Pinski pinskia@gcc.gnu.org
struct B
{
virtual void Foo ();
};
void B::Foo ()
{
}
struct D : virtual B
{
};
struct E
{
B *ptr;
E (B *);
};
static B *ptr;
E::E (B *ptr_)
:ptr (ptr_)
{
}
struct G : D, E
{
G ();
};
G::G ()
: E (this)
{
}
int main ()
{
G object;
return object.ptr != &object;
}