This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: [mingw/cygwin] Add "selectany" (=linkonce) attribute for initialized global data


On Sun, Mar 06, 2005 at 06:04:02PM +1300, Danny Smith wrote:
>The apended patch adds the "selectany" attribute, which causes an
>initialized global variable to have link-once semantics, for windows
>targets.  The attribute is declared on other compilers using the
>synonym __declspec(selectany)) and is commonly used in MS win32api
>headers to define ids (GUID objects) used to register Common Object
>Model (COM) "interfaces". It is also use extensively in such COM code
>as MS's proprietary "Active Template Library" (ATL) to allow in-header
>definition of static data members of C++ classes.
>
>I have only added this as a subtarget attribute for windows targets,
>since it specifies a very restricted type of COMDAT linkage that, AFAIK,
>is common only in the MS world.  Does it have any wider utility?
>
>Bootstrapped and tested on i686-pc-mingw32 with C, C++.
>gcc version 4.1.0 20050304 (experimental)
>
>OK for mainline?

Since this is all windows-only, it seems like you have the authority to
check this in.

cgf

>Changelog
>
>2005-03-06  Danny Smith  <dannysmith@users.sourceforge.net>
>
>	* config/i386/cygming.h (SUBTARGET_ATTRIBUTE_TABLE): Define,
>	with entry for selectany attribute.
>	* config/i386/i386-protos.h (ix86_handle_selectany_attribute):
>	Declare.
>	* config/i386/winnt.c (ix86_handle_selectany_attribute): Define.
>	(i386_pe_asm_named_section): Handle sections generated by
>	selectany attribute.
>	* doc/extend.texi (selectany): Document attribute.
>	
>testsuite/Changelog
>
>	* g++.dg/ext/selectany1.C: New file. Test for linkonce sections.
>	* g++.dg/ext/selectany2.C: New file. Test for errors with invalid
>	selectany usage.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]