* defaults.h (TARGET_DECLSPEC): New macro.
* c-cppbuiltin.c (c_cpp_builtins): Handle TARGET_DECLSPEC.
* config/arm/pe.h (SUBTARGET_CPP_SPEC): Remove __declspec support.
* config/arm/symbian. (TARGET_DLLIMPORT_DECL_ATTRIBUTES): Define.
* config/i386/beof-elf.h (TARGET_OS_CPP_BUILTINS): Remove
__declspec support.
(TARGET_DECLSPEC): Define.
* config/i386/cygming.h (TARGET_OS_CPP_BUILTINS): Remove
__declspec support.
* config/i386/i386-interix.h (TARGET_OS_CPP_BUILTINS): Remove
__declspec support.
(TARGET_DECLSPEC): Define.
* config/mcore/mcore.h (TARGET_CPU_CPP_BUILTINS): Remove
__declspec support.
* config/sh/symbian-pre.h (SUBTARGET_CPP_SPEC): Remove __declspec
support.
* doc/tm.texi (TARGET_DECLSPEC): Document.
* doc/extend.texi: Fix typo in comment.
From-SVN: r85571
+2004-08-04 Mark Mitchell <mark@codesourcery.com>
+
+ * defaults.h (TARGET_DECLSPEC): New macro.
+ * c-cppbuiltin.c (c_cpp_builtins): Handle TARGET_DECLSPEC.
+ * config/arm/pe.h (SUBTARGET_CPP_SPEC): Remove __declspec support.
+ * config/arm/symbian. (TARGET_DLLIMPORT_DECL_ATTRIBUTES): Define.
+ * config/i386/beof-elf.h (TARGET_OS_CPP_BUILTINS): Remove
+ __declspec support.
+ (TARGET_DECLSPEC): Define.
+ * config/i386/cygming.h (TARGET_OS_CPP_BUILTINS): Remove
+ __declspec support.
+ * config/i386/i386-interix.h (TARGET_OS_CPP_BUILTINS): Remove
+ __declspec support.
+ (TARGET_DECLSPEC): Define.
+ * config/mcore/mcore.h (TARGET_CPU_CPP_BUILTINS): Remove
+ __declspec support.
+ * config/sh/symbian-pre.h (SUBTARGET_CPP_SPEC): Remove __declspec
+ support.
+ * doc/tm.texi (TARGET_DECLSPEC): Document.
+
+ * doc/extend.texi: Fix typo in comment.
+
2004-08-04 Paul Brook <paul@codesourcery.com>
* target-def.h (TARGET_CXX_CDTOR_RETURNS_THIS): Define.
TARGET_CPU_CPP_BUILTINS ();
TARGET_OS_CPP_BUILTINS ();
TARGET_OBJFMT_CPP_BUILTINS ();
+
+ /* Support the __declspec keyword by turning them into attributes.
+ Note that the current way we do this may result in a collision
+ with predefined attributes later on. This can be solved by using
+ one attribute, say __declspec__, and passing args to it. The
+ problem with that approach is that args are not accumulated: each
+ new appearance would clobber any existing args. */
+ if (TARGET_DECLSPEC)
+ builtin_define ("__declspec(x)=__attribute__((x))");
}
/* Pass an object-like macro. If it doesn't lie in the user's
merge_decl_attributes. */
#define TARGET_DLLIMPORT_DECL_ATTRIBUTES
-/* Support the __declspec keyword by turning them into attributes.
- We currently only support: naked, dllimport, and dllexport.
- Note that the current way we do this may result in a collision with
- predefined attributes later on. This can be solved by using one attribute,
- say __declspec__, and passing args to it. The problem with that approach
- is that args are not accumulated: each new appearance would clobber any
- existing args. */
#undef SUBTARGET_CPP_SPEC
-#define SUBTARGET_CPP_SPEC "-D__pe__ -D__declspec(x)=__attribute__((x))"
+#define SUBTARGET_CPP_SPEC "-D__pe__"
/* Experimental addition for pr 7885.
"memmove". We cannot simply set flag_no_builtin in arm.c because
(a) flag_no_builtin is not declared in language-independent code,
and (b) that would prevent users from explicitly overriding the
- default with -fno-builtin, which may sometimes be useful.
+ default with -fbuiltin, which may sometimes be useful.
Make all symbols hidden by default. Symbian OS expects that all
exported symbols will be explicitly marked with
#define LINK_SPEC "%{mbig-endian:-EB} %{mlittle-endian:-EL} " \
"%{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic} " \
"-X"
+
+/* Support the "dllimport" attribute. */
+#define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1
#undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE_SIZE 16
+#define TARGET_DECLSPEC 1
+
#define TARGET_OS_CPP_BUILTINS() \
do \
{ \
builtin_define ("_X86_"); \
builtin_define ("__stdcall=__attribute__((__stdcall__))"); \
builtin_define ("__cdecl=__attribute__((__cdecl__))"); \
- builtin_define ("__declspec(x)=__attribute__((x))"); \
builtin_assert ("system=beos"); \
if (flag_pic) \
{ \
#define MAYBE_UWIN_CPP_BUILTINS() /* Nothing. */
-/* Support the __declspec keyword by turning them into attributes.
- We currently only support: dllimport and dllexport.
- Note that the current way we do this may result in a collision with
- predefined attributes later on. This can be solved by using one attribute,
- say __declspec__, and passing args to it. The problem with that approach
- is that args are not accumulated: each new appearance would clobber any
- existing args. */
-
#define TARGET_OS_CPP_BUILTINS() \
do \
{ \
builtin_define ("__stdcall=__attribute__((__stdcall__))"); \
builtin_define ("__fastcall=__attribute__((__fastcall__))"); \
builtin_define ("__cdecl=__attribute__((__cdecl__))"); \
- builtin_define ("__declspec(x)=__attribute__((x))"); \
if (!flag_iso) \
{ \
builtin_define ("_stdcall=__attribute__((__stdcall__))"); \
#define ASM_LOAD_ADDR(loc, reg) " leal " #loc "," #reg "\n"
+#define TARGET_DECLSPEC 1
+
/* cpp handles __STDC__ */
#define TARGET_OS_CPP_BUILTINS() \
do \
builtin_define ("_X86_=1"); \
builtin_define ("__stdcall=__attribute__((__stdcall__))"); \
builtin_define ("__cdecl=__attribute__((__cdecl__))"); \
- builtin_define ("__declspec(x)=__attribute__((x))"); \
builtin_assert ("system=unix"); \
builtin_assert ("system=interix"); \
if (preprocessing_asm_p ()) \
merge_decl_attributes. */
#define TARGET_DLLIMPORT_DECL_ATTRIBUTES
-/* Support the __declspec keyword by turning them into attributes.
- We currently only support: dllexport and dllimport.
- Note that the current way we do this may result in a collision with
- predefined attributes later on. This can be solved by using one attribute,
- say __declspec__, and passing args to it. The problem with that approach
- is that args are not accumulated: each new appearance would clobber any
- existing args. */
#define TARGET_CPU_CPP_BUILTINS() \
do \
{ \
builtin_define ("__mcore__"); \
builtin_define ("__MCORE__"); \
- builtin_define ("__declspec(x)=__attribute__((x))"); \
if (TARGET_LITTLE_END) \
builtin_define ("__MCORELE__"); \
else \
/* Default to using the Renesas ABI. */
#define TARGET_ABI_DEFAULT RENESAS_BIT
-/* Support the __declspec keyword by turning them into attributes.
- We currently only support: naked, dllimport, and dllexport.
- Note that the current way we do this may result in a collision with
- predefined attributes later on. This can be solved by using one attribute,
- say __declspec__, and passing args to it. The problem with that approach
- is that args are not accumulated: each new appearance would clobber any
- existing args. */
-#define SUBTARGET_CPP_SPEC "-D__declspec(x)=__attribute__((x))"
+#define SUBTARGET_CPP_SPEC ""
/* Get tree.c to declare merge_dllimport_decl_attributes(). */
#define TARGET_DLLIMPORT_DECL_ATTRIBUTES
#define PIC_OFFSET_TABLE_REGNUM INVALID_REGNUM
#endif
+#ifndef TARGET_DECLSPEC
+#ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES
+/* If the target supports the "dllimport" attribute, users are
+ probably used to the "__declspec" syntax. */
+#define TARGET_DECLSPEC 1
+#else
+#define TARGET_DECLSPEC 0
+#endif
+#endif
+
/* By default, the preprocessor should be invoked the same way in C++
as in C. */
#ifndef CPLUSPLUS_CPP_SPEC
See the ELF gABI for complete details, but the short story is:
@table @dfn
-@c keep this list of visibilies in alphabetical order.
+@c keep this list of visibilities in alphabetical order.
@item default
Default visibility is the normal case for ELF. This value is
in @file{i386/cygwin.h} and @file{i386/i386.c}, for example.
@end deftypefn
+@defmac TARGET_DECLSPEC
+Define this macro to a non-zero value if you want to treat
+@code{__declspec(X)} as equivalent to @code{__attribute((X))}. By
+default, this behavior is enabled only for targets that define
+@code{TARGET_DLLIMPORT_DECL_ATTRIBUTES}. The current implementation
+of @code{__declspec} is via a built-in macro, but you should not rely
+on this implementation detail.
+@end defmac
+
@deftypefn {Target Hook} void TARGET_INSERT_ATTRIBUTES (tree @var{node}, tree *@var{attr_ptr})
Define this target hook if you want to be able to add attributes to a decl
when it is being created. This is normally useful for back ends which