This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: egcs-1.0 bug: static members in template classes
- To: gloth at unknown dot westfalen dot de (Tobias Gloth), egcs-bugs at cygnus dot com
- Subject: Re: egcs-1.0 bug: static members in template classes
- From: Jason Merrill <jason at cygnus dot com>
- Date: 04 Dec 1997 17:30:28 -0800
- References: <m0xdlhC-000wIgC.cygnus.egcs.bugs@unknown.westfalen.de>
>>>>> Tobias Gloth <gloth@unknown.westfalen.de> writes:
> There's a problem with static members in template classes still around.
> It doesn't show up if I compile everything with -frepo, but someone
> told me that this flag should not be needed with ELF...
I thought I already sent you this patch. Jeff, this should go into 1.0.1.
Thu Nov 27 00:59:46 1997 Jason Merrill <jason@yorick.cygnus.com>
* cp-tree.h (struct lang_decl_flags): Add comdat.
(DECL_COMDAT): New macro.
* decl.c (duplicate_decls): Propagate it.
(cp_finish_decl): Handle it.
* decl2.c (import_export_decl): Just set DECL_COMDAT on VAR_DECLs.
Index: cp-tree.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/cp/cp-tree.h,v
retrieving revision 1.299
retrieving revision 1.300
diff -c -p -r1.299 -r1.300
*** cp-tree.h 1997/11/15 08:37:16 1.299
--- cp-tree.h 1997/11/27 19:25:19 1.300
*************** struct lang_decl_flags
*** 943,949 ****
unsigned nonconverting : 1;
unsigned declared_inline : 1;
unsigned not_really_extern : 1;
! unsigned dummy : 5;
tree access;
tree context;
--- 943,950 ----
unsigned nonconverting : 1;
unsigned declared_inline : 1;
unsigned not_really_extern : 1;
! unsigned comdat : 1;
! unsigned dummy : 4;
tree access;
tree context;
*************** extern int flag_new_for_scope;
*** 1419,1424 ****
--- 1410,1419 ----
#define DECL_REALLY_EXTERN(NODE) \
(DECL_EXTERNAL (NODE) && ! DECL_NOT_REALLY_EXTERN (NODE))
+
+ /* Used to tell cp_finish_decl that it should approximate comdat linkage
+ as best it can for this decl. */
+ #define DECL_COMDAT(NODE) (DECL_LANG_SPECIFIC (NODE)->decl_flags.comdat)
#define THUNK_DELTA(DECL) ((DECL)->decl.frame_size.i)
Index: decl.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/cp/decl.c,v
retrieving revision 1.735
retrieving revision 1.736
diff -c -p -r1.735 -r1.736
*** decl.c 1997/11/21 20:29:56 1.735
--- decl.c 1997/11/27 19:25:23 1.736
*************** duplicate_decls (newdecl, olddecl)
*** 2856,2861 ****
--- 2856,2862 ----
{
DECL_INTERFACE_KNOWN (newdecl) |= DECL_INTERFACE_KNOWN (olddecl);
DECL_NOT_REALLY_EXTERN (newdecl) |= DECL_NOT_REALLY_EXTERN (olddecl);
+ DECL_COMDAT (newdecl) |= DECL_COMDAT (olddecl);
}
if (TREE_CODE (newdecl) == FUNCTION_DECL)
*************** cp_finish_decl (decl, init, asmspec_tree
*** 6736,6741 ****
--- 6737,6768 ----
= build_static_name (current_function_decl, DECL_NAME (decl));
else if (! DECL_ARTIFICIAL (decl))
cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl);
+ }
+
+ else if (TREE_CODE (decl) == VAR_DECL
+ && DECL_LANG_SPECIFIC (decl)
+ && DECL_COMDAT (decl))
+ {
+ /* Dynamically initialized vars go into common. */
+ if (DECL_INITIAL (decl) == NULL_TREE
+ || DECL_INITIAL (decl) == error_mark_node)
+ DECL_COMMON (decl) = 1;
+ else if (EMPTY_CONSTRUCTOR_P (DECL_INITIAL (decl)))
+ {
+ DECL_COMMON (decl) = 1;
+ DECL_INITIAL (decl) = error_mark_node;
+ }
+ else
+ {
+ /* Statically initialized vars are weak or comdat, if
+ supported. */
+ if (flag_weak)
+ make_decl_one_only (decl);
+ else
+ /* we can't do anything useful; leave vars for explicit
+ instantiation. */
+ DECL_EXTERNAL (decl) = 1;
+ }
}
if (TREE_CODE (decl) == VAR_DECL && DECL_VIRTUAL_P (decl))
Index: decl2.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/cp/decl2.c,v
retrieving revision 1.355
retrieving revision 1.356
diff -c -p -r1.355 -r1.356
*** decl2.c 1997/11/27 07:30:40 1.355
--- decl2.c 1997/11/27 19:25:28 1.356
*************** import_export_decl (decl)
*** 2810,2835 ****
{
if (TREE_CODE (decl) == FUNCTION_DECL)
comdat_linkage (decl);
- /* Dynamically initialized vars go into common. */
- else if (DECL_INITIAL (decl) == NULL_TREE
- || DECL_INITIAL (decl) == error_mark_node)
- DECL_COMMON (decl) = 1;
- else if (EMPTY_CONSTRUCTOR_P (DECL_INITIAL (decl)))
- {
- DECL_COMMON (decl) = 1;
- DECL_INITIAL (decl) = error_mark_node;
- }
else
! {
! /* Statically initialized vars are weak or comdat, if
! supported. */
! if (flag_weak)
! make_decl_one_only (decl);
! else
! /* we can't do anything useful; leave vars for explicit
! instantiation. */
! DECL_NOT_REALLY_EXTERN (decl) = 0;
! }
}
else
DECL_NOT_REALLY_EXTERN (decl) = 0;
--- 2810,2817 ----
{
if (TREE_CODE (decl) == FUNCTION_DECL)
comdat_linkage (decl);
else
! DECL_COMDAT (decl) = 1;
}
else
DECL_NOT_REALLY_EXTERN (decl) = 0;