From 3c5c992fb35721740819b519e532b3f3e244e323 Mon Sep 17 00:00:00 2001 From: mmitchel Date: Wed, 4 Aug 2004 19:37:19 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85571 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 22 ++++++++++++++++++++++ gcc/c-cppbuiltin.c | 9 +++++++++ gcc/config/arm/pe.h | 9 +-------- gcc/config/arm/symbian.h | 5 ++++- gcc/config/i386/beos-elf.h | 3 ++- gcc/config/i386/cygming.h | 9 --------- gcc/config/i386/i386-interix.h | 3 ++- gcc/config/mcore/mcore.h | 8 -------- gcc/config/sh/symbian-pre.h | 9 +-------- gcc/defaults.h | 10 ++++++++++ gcc/doc/extend.texi | 2 +- gcc/doc/tm.texi | 9 +++++++++ 12 files changed, 61 insertions(+), 37 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 64fff1d6140..0461d107dff 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,25 @@ +2004-08-04 Mark Mitchell + + * 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 * target-def.h (TARGET_CXX_CDTOR_RETURNS_THIS): Define. diff --git a/gcc/c-cppbuiltin.c b/gcc/c-cppbuiltin.c index 3f0f688861d..441a38e3b8c 100644 --- a/gcc/c-cppbuiltin.c +++ b/gcc/c-cppbuiltin.c @@ -426,6 +426,15 @@ c_cpp_builtins (cpp_reader *pfile) 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 diff --git a/gcc/config/arm/pe.h b/gcc/config/arm/pe.h index 8eea54ce1f2..7db549e68f3 100644 --- a/gcc/config/arm/pe.h +++ b/gcc/config/arm/pe.h @@ -42,15 +42,8 @@ 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. diff --git a/gcc/config/arm/symbian.h b/gcc/config/arm/symbian.h index 05930d4548d..2f8320de99e 100644 --- a/gcc/config/arm/symbian.h +++ b/gcc/config/arm/symbian.h @@ -30,7 +30,7 @@ "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 @@ -48,3 +48,6 @@ #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 diff --git a/gcc/config/i386/beos-elf.h b/gcc/config/i386/beos-elf.h index 50c39264bc0..b0de9bba834 100644 --- a/gcc/config/i386/beos-elf.h +++ b/gcc/config/i386/beos-elf.h @@ -55,6 +55,8 @@ Boston, MA 02111-1307, USA. */ #undef WCHAR_TYPE_SIZE #define WCHAR_TYPE_SIZE 16 +#define TARGET_DECLSPEC 1 + #define TARGET_OS_CPP_BUILTINS() \ do \ { \ @@ -63,7 +65,6 @@ Boston, MA 02111-1307, USA. */ 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) \ { \ diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h index 69d7f7920ae..9c2e22aa706 100644 --- a/gcc/config/i386/cygming.h +++ b/gcc/config/i386/cygming.h @@ -72,14 +72,6 @@ Boston, MA 02111-1307, USA. */ #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 \ { \ @@ -88,7 +80,6 @@ Boston, MA 02111-1307, USA. */ 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__))"); \ diff --git a/gcc/config/i386/i386-interix.h b/gcc/config/i386/i386-interix.h index 2a99ce549a7..4119aa2d184 100644 --- a/gcc/config/i386/i386-interix.h +++ b/gcc/config/i386/i386-interix.h @@ -54,6 +54,8 @@ Boston, MA 02111-1307, USA. */ #define ASM_LOAD_ADDR(loc, reg) " leal " #loc "," #reg "\n" +#define TARGET_DECLSPEC 1 + /* cpp handles __STDC__ */ #define TARGET_OS_CPP_BUILTINS() \ do \ @@ -64,7 +66,6 @@ Boston, MA 02111-1307, USA. */ 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 ()) \ diff --git a/gcc/config/mcore/mcore.h b/gcc/config/mcore/mcore.h index b800a932659..dde4e093c50 100644 --- a/gcc/config/mcore/mcore.h +++ b/gcc/config/mcore/mcore.h @@ -35,19 +35,11 @@ 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 \ diff --git a/gcc/config/sh/symbian-pre.h b/gcc/config/sh/symbian-pre.h index aa23535bda1..44fb4a939e2 100644 --- a/gcc/config/sh/symbian-pre.h +++ b/gcc/config/sh/symbian-pre.h @@ -27,14 +27,7 @@ /* 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 diff --git a/gcc/defaults.h b/gcc/defaults.h index cd45f9180ec..3cd779ca29d 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -415,6 +415,16 @@ do { fputs (integer_asm_op (POINTER_SIZE / BITS_PER_UNIT, TRUE), FILE); \ #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 diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 291e4fd44c8..1b4b76b569f 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -2177,7 +2177,7 @@ int i __attribute__ ((visibility ("hidden"))); 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 diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index cc3cfeebee4..2a0147cfd4d 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -8346,6 +8346,15 @@ as the expansion of @code{TARGET_MERGE_DECL_ATTRIBUTES}. This is done 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 -- 2.11.0