This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] fix bug 2125
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH] fix bug 2125
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Wed, 25 Apr 2001 09:35:14 +0100
- Organization: Codesourcery LLC
Hi,
I've installed this patch on both branch and mainline, as it fixes a 2.95
regression.
namespace scope user declared typedefs never had their DECL_CONTEXT set.
When one of these clobered the implicit typedef of a struct, bad
things happened.
built & tested on i686-pc-linux-gnu, approved by Mark.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-04-24 Nathan Sidwell <nathan@codesourcery.com>
* decl.c (grokdeclarator): Set context of namespace scope
TYPE_DECLS.
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.747.2.19
diff -c -3 -p -r1.747.2.19 decl.c
*** decl.c 2001/04/20 23:59:54 1.747.2.19
--- decl.c 2001/04/24 07:56:21
*************** grokdeclarator (declarator, declspecs, d
*** 11018,11025 ****
decl = build_lang_decl (TYPE_DECL, declarator, type);
}
else
! decl = build_decl (TYPE_DECL, declarator, type);
!
/* If the user declares "typedef struct {...} foo" then the
struct will have an anonymous name. Fill that name in now.
Nothing can refer to it, so nothing needs know about the name
--- 11018,11029 ----
decl = build_lang_decl (TYPE_DECL, declarator, type);
}
else
! {
! decl = build_decl (TYPE_DECL, declarator, type);
! if (!current_function_decl)
! DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
! }
!
/* If the user declares "typedef struct {...} foo" then the
struct will have an anonymous name. Fill that name in now.
Nothing can refer to it, so nothing needs know about the name
// Build don't link:
//
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 11 April 2001 <nathan@codesourcery.com>
// Origin:stephen.webb@cybersafe.com
// Bug 2125. TYPE_DECLS never had their DECL_CONTEXT set, which
// confused forward references to classes.
typedef void T;
namespace A {
class C;
typedef class C C;
typedef int T;
class C
{
T i; // got bogus error, found wrong T
};
}