This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Updated] dllimport/dllexport attributes for Win32/BeOS
- To: Jason Merrill <jason at cygnus dot com>
- Subject: Re: [Updated] dllimport/dllexport attributes for Win32/BeOS
- From: Mumit Khan <khan at xraylith dot wisc dot edu>
- Date: Thu, 25 Jun 1998 22:40:28 -0500 (CDT)
- Cc: Jeffrey A Law <law at cygnus dot com>, egcs-patches at cygnus dot com
On 25 Jun 1998, Jason Merrill wrote:
> It would be cleaner to add a new macro to indicate that you can't just take
> the address, and set that in mark_dllimport.
>
Would something like the following be acceptable (I'm only showing tree
changes, the rest will follow if ok):
Thu Jun 25 22:27:04 1998 Mumit Khan <khan@xraylith.wisc.edu>
* tree.h (DECL_DYNAMIC_IMPORT, DECL_DYNAMIC_EXPORT): New accessor
macros.
(struct tree_decl): Add dynamic_import and dynamic_export fields.
* tree.c (staticp): Don't treat DLL imported functions and variables
at scope as static.
Index: tree.h
===================================================================
RCS file: /home/khan/src/CVSROOT/gnu/egcs/gcc/tree.h,v
retrieving revision 1.1.1.2
diff -u -3 -p -r1.1.1.2 tree.h
--- tree.h 1998/05/24 23:38:48 1.1.1.2
+++ tree.h 1998/06/26 02:42:21
@@ -1186,6 +1186,12 @@ struct tree_type
#define DECL_LANG_FLAG_6(NODE) (DECL_CHECK (NODE)->decl.lang_flag_6)
#define DECL_LANG_FLAG_7(NODE) (DECL_CHECK (NODE)->decl.lang_flag_7)
+/* Used to indicate that this DECL is imported from a dynamic library. */
+#define DECL_DYNAMIC_IMPORT(NODE) (DECL_CHECK (NODE)->decl.dynamic_import)
+
+/* Used to indicate that this DECL is exported from a dynamic library. */
+#define DECL_DYNAMIC_EXPORT(NODE) (DECL_CHECK (NODE)->decl.dynamic_export)
+
struct tree_decl
{
char common[sizeof (struct tree_common)];
@@ -1226,6 +1232,9 @@ struct tree_decl
unsigned lang_flag_5 : 1;
unsigned lang_flag_6 : 1;
unsigned lang_flag_7 : 1;
+
+ unsigned dynamic_import : 1;
+ unsigned dynamic_export : 1;
/* For a FUNCTION_DECL, if inline, this is the size of frame needed.
If built-in, this is the code for which built-in function.
Index: tree.c
===================================================================
RCS file: /home/khan/src/CVSROOT/gnu/egcs/gcc/tree.c,v
retrieving revision 1.1.1.2
diff -u -3 -p -r1.1.1.2 tree.c
--- tree.c 1998/05/24 23:38:48 1.1.1.2
+++ tree.c 1998/06/26 02:48:31
@@ -2255,10 +2255,16 @@ staticp (arg)
{
case FUNCTION_DECL:
/* Nested functions aren't static, since taking their address
- involves a trampoline. */
- return decl_function_context (arg) == 0 || DECL_NO_STATIC_CHAIN (arg);
+ involves a trampoline. Also, don't treat DLL imported functions
+ as static since taking their address involves initialization. */
+ return (decl_function_context (arg) == 0 || DECL_NO_STATIC_CHAIN (arg))
+ && ! DECL_DYNAMIC_IMPORT (arg);
+
case VAR_DECL:
- return TREE_STATIC (arg) || DECL_EXTERNAL (arg);
+ /* Don't treat DLL imported variables as static since taking their
+ address involves initialization. */
+ return (TREE_STATIC (arg) || DECL_EXTERNAL (arg))
+ && ! DECL_DYNAMIC_IMPORT (arg);
case CONSTRUCTOR:
return TREE_STATIC (arg);