summaryrefslogtreecommitdiff
path: root/gcc/config/i386/winnt-cxx.c
diff options
context:
space:
mode:
authordannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-04 08:00:56 +0000
committerdannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-04 08:00:56 +0000
commitf5b1f90b7b0020267c34487a1ab6da238c3712b3 (patch)
tree52eac40af87711dd8c6d296e9f80c346db50320c /gcc/config/i386/winnt-cxx.c
parent678ca12c7a43d93eae74bca15514013c6c2a3106 (diff)
downloadgcc-f5b1f90b7b0020267c34487a1ab6da238c3712b3.tar.gz
gcc
* config/i386/winnt-cxx.c (i386_pe_type_dllimport_p): Don't ignore dllimport attribute of virtual methods. gcc/cp * class.c (check_for_override): Don't remove dllmport attribute of virtual methods. gcc/testsuite * g++.dg/ext/dllimport12.C: Update comments git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123492 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/i386/winnt-cxx.c')
-rw-r--r--gcc/config/i386/winnt-cxx.c95
1 files changed, 36 insertions, 59 deletions
diff --git a/gcc/config/i386/winnt-cxx.c b/gcc/config/i386/winnt-cxx.c
index 6123ebbcdc3..a6a8510720b 100644
--- a/gcc/config/i386/winnt-cxx.c
+++ b/gcc/config/i386/winnt-cxx.c
@@ -38,66 +38,43 @@ Boston, MA 02110-1301, USA. */
bool
i386_pe_type_dllimport_p (tree decl)
{
- gcc_assert (TREE_CODE (decl) == VAR_DECL
- || TREE_CODE (decl) == FUNCTION_DECL);
-
- if (TARGET_NOP_FUN_DLLIMPORT && TREE_CODE (decl) == FUNCTION_DECL)
- return false;
-
- /* We ignore the dllimport attribute for inline member functions.
- This differs from MSVC behavior which treats it like GNUC
- 'extern inline' extension. Also ignore for template
- instantiations with linkonce semantics and artificial methods. */
- if (TREE_CODE (decl) == FUNCTION_DECL
- && (DECL_DECLARED_INLINE_P (decl)
- || DECL_TEMPLATE_INSTANTIATION (decl)
- || DECL_ARTIFICIAL (decl)))
- return false;
-
- /* Since we can't treat a pointer to a dllimport'd symbol as a
- constant address, we turn off the attribute on C++ virtual
- methods to allow creation of vtables using thunks. */
- else if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE
- && DECL_VIRTUAL_P (decl))
- {
- /* Even though we ignore the attribute from the start, warn if we later see
- an out-of class definition, as we do for other member functions in
- tree.c:merge_dllimport_decl_attributes. If this is the key method, the
- definition may affect the import-export status of vtables, depending
- on how we handle MULTIPLE_SYMBOL_SPACES in cp/decl2.c. */
- if (DECL_INITIAL (decl))
- {
- warning (OPT_Wattributes, "%q+D redeclared without dllimport attribute: "
- "previous dllimport ignored", decl);
-#ifdef PE_DLL_DEBUG
- if (decl == CLASSTYPE_KEY_METHOD (DECL_CONTEXT (decl)))
- warning (OPT_Wattributes, "key method %q+D of dllimport'd class defined"
- decl);
-#endif
- }
- return false;
- }
-
- /* Don't mark defined functions as dllimport. This code will only be
- reached if we see a non-inline function defined out-of-class. */
- else if (TREE_CODE (decl) == FUNCTION_DECL
- && (DECL_INITIAL (decl)))
+ gcc_assert (TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == FUNCTION_DECL);
+
+ if (TARGET_NOP_FUN_DLLIMPORT && TREE_CODE (decl) == FUNCTION_DECL)
+ return false;
+
+ /* We ignore the dllimport attribute for inline member functions.
+ This differs from MSVC behavior which treats it like GNUC
+ 'extern inline' extension. Also ignore for template
+ instantiations with linkonce semantics and artificial methods. */
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ && (DECL_DECLARED_INLINE_P (decl)
+ || DECL_TEMPLATE_INSTANTIATION (decl)
+ || DECL_ARTIFICIAL (decl)))
+ return false;
+
+
+ /* Don't mark defined functions as dllimport. This code will only be
+ reached if we see a non-inline function defined out-of-class. */
+ else if (TREE_CODE (decl) == FUNCTION_DECL
+ && (DECL_INITIAL (decl)))
+ return false;
+
+ /* Don't allow definitions of static data members in dllimport class,
+ If vtable data is marked as DECL_EXTERNAL, import it; otherwise just
+ ignore the class attribute. */
+ else if (TREE_CODE (decl) == VAR_DECL
+ && TREE_STATIC (decl) && TREE_PUBLIC (decl)
+ && !DECL_EXTERNAL (decl))
+ {
+ if (!DECL_VIRTUAL_P (decl))
+ error ("definition of static data member %q+D of "
+ "dllimport'd class", decl);
return false;
+ }
- /* Don't allow definitions of static data members in dllimport class,
- If vtable data is marked as DECL_EXTERNAL, import it; otherwise just
- ignore the class attribute. */
- else if (TREE_CODE (decl) == VAR_DECL
- && TREE_STATIC (decl) && TREE_PUBLIC (decl)
- && !DECL_EXTERNAL (decl))
- {
- if (!DECL_VIRTUAL_P (decl))
- error ("definition of static data member %q+D of "
- "dllimport'd class", decl);
- return false;
- }
-
- return true;
+ return true;
}
@@ -143,7 +120,7 @@ i386_pe_adjust_class_at_definition (tree t)
definition. We recheck the class members at RTL generation to
emit warnings if this has happened. Definition of static data member
of dllimport'd class always causes an error (as per MS compiler).
- */
+ */
/* Check static VAR_DECL's. */
for (member = TYPE_FIELDS (t); member; member = TREE_CHAIN (member))