bool i386_pe_dllimport_p (tree decl) { if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL) return false; /* Lookup the attribute in addition to checking the DECL_DLLIMPORT_P flag. We may need to override an earlier decision. */ if (DECL_DLLIMPORT_P (decl) && lookup_attribute ("dllimport", DECL_ATTRIBUTES (decl))) { /* Make a final check to see if this is a definition before we generate RTL for an indirect reference. */ if (!DECL_EXTERNAL (decl)) { error ("%q+D: definition is marked as dllimport", decl); DECL_DLLIMPORT_P (decl) = 0; return false; } return true; } /* The DECL_DLLIMPORT_P flag was set for decls in the class definition by targetm.cxx.adjust_class_at_definition. Check again to emit warnings if the class attribute has been overridden by an out-of-class definition. */ else if (associated_type (decl) && lookup_attribute ("dllimport", TYPE_ATTRIBUTES (associated_type (decl)))) return i386_pe_type_dllimport_p (decl); return false; }
static inline void maybe_add_dllimport (tree decl) { /* BEGIN GCC-XML MODIFICATIONS 2009-04-24 */ /* Somehow dllimport ends up on the VAR_DECL for the 'B' vtable: class A {}; struct __attribute__((dllimport)) B: virtual public A { ~B() {} }; Then 'maybe_emit_vtables' calls 'store_init_value' which eventually calls 'initializer_constant_valid_p' and 'staticp'. The DECL_DLLIMPORT_P mark requires runtime initialization of the vtable, which is not allowed, and results in an ICE. There is code in "class.c" which removes the dllimport attribute but it never seems to be called for the vtable VAR_DECL. We workaround the problem for gccxml by disabling the mark altogether, as it seems to be used only for code generation. */ #if 0 if (i386_pe_type_dllimport_p (decl)) DECL_DLLIMPORT_P (decl) = 1; #else (void)decl; #endif /* END GCC-XML MODIFICATIONS 2009-04-24 */ }
static inline void maybe_add_dllimport (tree decl) { if (i386_pe_type_dllimport_p (decl)) DECL_DLLIMPORT_P (decl) = 1; }