Commit ac478ac0 by Jason Merrill Committed by Jeff Law

cygwin32.h (VALID_MACHINE_TYPE_ATTRIBUTE): New macro.

Tue Jul 28 23:29:04 1998  Jason Merrill  <jason@yorick.cygnus.com>
        * i386/cygwin32.h (VALID_MACHINE_TYPE_ATTRIBUTE): New macro.
        * i386/winnt.c (associated_type): New fn.
        (i386_pe_valid_type_attribute_p): New fn.
        (i386_pe_check_vtable_importexport): Remove.
        (i386_pe_dllexport_p): Use associated_type.
        (i386_pe_dllimport_p): Likewise.
        From Antonio M. O. Neto <anmendes@cruzeironet.com.br>:
        * i386.c (i386_valid_type_attribute_p): Also accept
        attributes for METHOD_TYPEs.

From-SVN: r21456
parent 28372f41
Tue Jul 28 23:29:04 1998 Jason Merrill <jason@yorick.cygnus.com>
* i386/cygwin32.h (VALID_MACHINE_TYPE_ATTRIBUTE): New macro.
* i386/winnt.c (associated_type): New fn.
(i386_pe_valid_type_attribute_p): New fn.
(i386_pe_check_vtable_importexport): Remove.
(i386_pe_dllexport_p): Use associated_type.
(i386_pe_dllimport_p): Likewise.
From Antonio M. O. Neto <anmendes@cruzeironet.com.br>:
* i386.c (i386_valid_type_attribute_p): Also accept
attributes for METHOD_TYPEs.
Tue Jul 28 23:17:39 1998 Peter Gerwinski <peter@gerwinski.de> Tue Jul 28 23:17:39 1998 Peter Gerwinski <peter@gerwinski.de>
* tree.c (build_range_type): Copy TYPE_SIZE_UNIT. * tree.c (build_range_type): Copy TYPE_SIZE_UNIT.
......
...@@ -98,6 +98,15 @@ extern int i386_pe_valid_decl_attribute_p (); ...@@ -98,6 +98,15 @@ extern int i386_pe_valid_decl_attribute_p ();
#define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \ #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
i386_pe_valid_decl_attribute_p (DECL, ATTRIBUTES, IDENTIFIER, ARGS) i386_pe_valid_decl_attribute_p (DECL, ATTRIBUTES, IDENTIFIER, ARGS)
/* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
is a valid machine specific attribute for TYPE.
The attributes in ATTRIBUTES have previously been assigned to TYPE. */
#undef VALID_MACHINE_TYPE_ATTRIBUTE
#define VALID_MACHINE_TYPE_ATTRIBUTE(TYPE, ATTRIBUTES, IDENTIFIER, ARGS) \
i386_pe_valid_type_attribute_p (TYPE, ATTRIBUTES, IDENTIFIER, ARGS)
extern int i386_pe_valid_type_attribute_p ();
extern union tree_node *i386_pe_merge_decl_attributes (); extern union tree_node *i386_pe_merge_decl_attributes ();
#define MERGE_MACHINE_DECL_ATTRIBUTES(OLD, NEW) \ #define MERGE_MACHINE_DECL_ATTRIBUTES(OLD, NEW) \
i386_pe_merge_decl_attributes ((OLD), (NEW)) i386_pe_merge_decl_attributes ((OLD), (NEW))
......
...@@ -546,6 +546,7 @@ i386_valid_type_attribute_p (type, attributes, identifier, args) ...@@ -546,6 +546,7 @@ i386_valid_type_attribute_p (type, attributes, identifier, args)
tree args; tree args;
{ {
if (TREE_CODE (type) != FUNCTION_TYPE if (TREE_CODE (type) != FUNCTION_TYPE
&& TREE_CODE (type) != METHOD_TYPE
&& TREE_CODE (type) != FIELD_DECL && TREE_CODE (type) != FIELD_DECL
&& TREE_CODE (type) != TYPE_DECL) && TREE_CODE (type) != TYPE_DECL)
return 0; return 0;
......
...@@ -50,17 +50,40 @@ i386_pe_valid_decl_attribute_p (decl, attributes, attr, args) ...@@ -50,17 +50,40 @@ i386_pe_valid_decl_attribute_p (decl, attributes, attr, args)
tree attr; tree attr;
tree args; tree args;
{ {
if (args != NULL_TREE) if (args == NULL_TREE)
return 0; {
if (is_attribute_p ("dllexport", attr)) if (is_attribute_p ("dllexport", attr))
return 1; return 1;
if (is_attribute_p ("dllimport", attr)) if (is_attribute_p ("dllimport", attr))
return 1; return 1;
}
return i386_valid_decl_attribute_p (decl, attributes, attr, args); return i386_valid_decl_attribute_p (decl, attributes, attr, args);
} }
/* Return nonzero if ATTR is a valid attribute for TYPE.
ATTRIBUTES are any existing attributes and ARGS are the arguments
supplied with ATTR. */
int
i386_pe_valid_type_attribute_p (type, attributes, attr, args)
tree type;
tree attributes;
tree attr;
tree args;
{
if (args == NULL_TREE
&& (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE))
{
if (is_attribute_p ("dllexport", attr))
return 1;
if (is_attribute_p ("dllimport", attr))
return 1;
}
return i386_valid_type_attribute_p (type, attributes, attr, args);
}
/* Merge attributes in decls OLD and NEW. /* Merge attributes in decls OLD and NEW.
This handles the following situation: This handles the following situation:
...@@ -114,49 +137,33 @@ i386_pe_merge_decl_attributes (old, new) ...@@ -114,49 +137,33 @@ i386_pe_merge_decl_attributes (old, new)
return a; return a;
} }
/* Check a type that has a virtual table, and see if any virtual methods are /* Return the type that we should use to determine if DECL is
marked for import or export, and if so, arrange for the vtable to imported or exported. */
be imported or exported. */
static int static tree
i386_pe_check_vtable_importexport (type) associated_type (decl)
tree type; tree decl;
{ {
tree methods = TYPE_METHODS (type); tree t = NULL_TREE;
tree fndecl;
if (TREE_CODE (methods) == FUNCTION_DECL)
fndecl = methods;
else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
fndecl = TREE_VEC_ELT (methods, 0);
else
fndecl = TREE_VEC_ELT (methods, 1);
while (fndecl) /* In the C++ frontend, DECL_CONTEXT for a method doesn't actually refer
{ to the containing class. So we look at the 'this' arg. */
if (DECL_VIRTUAL_P (fndecl) || DECL_VINDEX (fndecl) != NULL_TREE) if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
{ {
tree exp = lookup_attribute ("dllimport", /* Artificial methods are not affected by the import/export status of
DECL_MACHINE_ATTRIBUTES (fndecl)); their class unless they are virtual. */
if (exp == 0) if (! DECL_ARTIFICIAL (decl) || DECL_VINDEX (decl))
exp = lookup_attribute ("dllexport", t = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl))));
DECL_MACHINE_ATTRIBUTES (fndecl));
if (exp)
return 1;
} }
else if (DECL_CONTEXT (decl)
&& TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (decl))) == 't')
t = DECL_CONTEXT (decl);
fndecl = TREE_CHAIN (fndecl); return t;
}
return 0;
} }
/* Return non-zero if DECL is a dllexport'd object. */ /* Return non-zero if DECL is a dllexport'd object. */
#if 0
tree current_class_type; /* FIXME */
#endif
int int
i386_pe_dllexport_p (decl) i386_pe_dllexport_p (decl)
tree decl; tree decl;
...@@ -170,22 +177,14 @@ i386_pe_dllexport_p (decl) ...@@ -170,22 +177,14 @@ i386_pe_dllexport_p (decl)
if (exp) if (exp)
return 1; return 1;
#if 0 /* This was a hack to get vtable's exported or imported since only one /* Class members get the dllexport status of their class. */
copy of them is ever output. Disabled pending better solution. */ if (associated_type (decl))
/* For C++, the vtables might have to be marked. */
if (TREE_CODE (decl) == VAR_DECL && DECL_VIRTUAL_P (decl))
{ {
if (TREE_PUBLIC (decl) exp = lookup_attribute ("dllexport",
&& DECL_EXTERNAL (decl) == 0 TYPE_ATTRIBUTES (associated_type (decl)));
&& (DECL_CONTEXT (decl) if (exp)
? i386_pe_check_vtable_importexport (DECL_CONTEXT (decl))
: current_class_type
? i386_pe_check_vtable_importexport (current_class_type)
: 0)
)
return 1; return 1;
} }
#endif
return 0; return 0;
} }
...@@ -209,22 +208,14 @@ i386_pe_dllimport_p (decl) ...@@ -209,22 +208,14 @@ i386_pe_dllimport_p (decl)
if (imp) if (imp)
return 1; return 1;
#if 0 /* This was a hack to get vtable's exported or imported since only one /* Class members get the dllimport status of their class. */
copy of them is ever output. Disabled pending better solution. */ if (associated_type (decl))
/* For C++, the vtables might have to be marked. */
if (TREE_CODE (decl) == VAR_DECL && DECL_VIRTUAL_P (decl))
{ {
if (TREE_PUBLIC (decl) imp = lookup_attribute ("dllimport",
&& DECL_EXTERNAL (decl) TYPE_ATTRIBUTES (associated_type (decl)));
&& (DECL_CONTEXT (decl) if (imp)
? i386_pe_check_vtable_importexport (DECL_CONTEXT (decl))
: current_class_type
? i386_pe_check_vtable_importexport (current_class_type)
: 0)
)
return 1; return 1;
} }
#endif
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment