diff options
author | Mark Mitchell <mark@codesourcery.com> | 2004-08-06 02:03:29 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2004-08-06 02:03:29 +0000 |
commit | b2ca370228811541d31d023ffd1280f5a819d8f2 (patch) | |
tree | 69d71a8f79d4ab453d9ed298e91ba4813f6f9760 /gcc/tree.c | |
parent | 01e054665da8e46a14bb326cee073e48ee0366ef (diff) | |
download | gcc-b2ca370228811541d31d023ffd1280f5a819d8f2.zip gcc-b2ca370228811541d31d023ffd1280f5a819d8f2.tar.gz gcc-b2ca370228811541d31d023ffd1280f5a819d8f2.tar.bz2 |
tree.c (handle_dll_attribute): Move here from i383/winnt.c.
* tree.c (handle_dll_attribute): Move here from i383/winnt.c.
Replace use of DECL_INLINE with DECL_DECLARED_INLINE_P. Set
DECL_VISIBLITY. Test TARGET_DLLIMPORT_DECL_ATTRIBUTES with #if.
* tree.h (handle_dll_attribute): Declare. Test
TARGET_DLLIMPORT_DECL_ATTRIBUTES with #if.
* c-common.h (c_determine_visibility): Declare.
* c-common.c (c_determine_visibility): New function.
* c-decl.c (finish_decl): Use it.
(finish_function): Likewise.
* defaults.h (TARGET_DLLIMPORT_DECL_ATTRIBUTES): Define it to
zero, by default. Use #if, not #ifdef, to test it.
* config/arm/arm.c (arm_attribute_table): Use
handle_dll_attribute. Test TARGET_DLLIMPORT_DECL_ATTRIBUTES with
#if.
* config/arm/pe.h (TARGET_DLLIMPORT_DECL_ATTRIBUTES): Define to 1.
* config/i386/cygming.h (TARGET_DLLIMPORT_DECL_ATTRIBUTES): Define
to 1.
* config/i386/i386-protos.h (ix86_handle_dll_attribute): Remove.
* config/i386/i386.c (ix86_attribute_table): Use
handle_dll_attribute for dllimport/dllexport. Test
TARGET_DLLIMPORT_DECL_ATTRIBUTES with #if.
* config/i386/winnt.c (ix86_handle_dll_attribute): Remove.
* config/mcore/mcore.h (TARGET_DLLIMPORT_DECL_ATTRIBUTES): Define
it to 1.
* config/mcore/mcore.c (TARGET_DLLIMPORT_DECL_ATTRIBUTES): Test it
with #if.
* config/sh/symbian-pre.h (TARGET_DLLIMPORT_DECL_ATTRIBUTES): Define
it to 1.
* doc/extend.texi (dllexport): Clarify and correct documentation.
(dllimport): Likewise.
* doc/tm.texi (TARGET_DLLIMPORT_DECL_ATTRIBUTES): Mention
handle_dll_attribute.
* decl.c (start_preparsed_function): Move determine_visibility
call.
* decl2.c (determine_visibility): Incorporate dllexport testing.
* g++.dg/ext/visibility/assign1.C: Use scan-hidden and
dg-require-visiblity.
* g++.dg/ext/visibility/fvisibility-inlines-hidden.C: Likewise.
* g++.dg/ext/visibility/fvisibility.C: Likewise.
* g++.dg/ext/visibility/memfuncts.C: Likewise.
* g++.dg/ext/visibility/new1.C: Likewise.
* g++.dg/ext/visibility/pragma.C: Likewise.
* g++.dg/ext/visibility/staticmemfuncts.C: Likewise.
* g++.dg/ext/visibility/virtual.C: Likewise.
* g++/dg/ext/visibility/visibility-1.C: Likewise.
* g++/dg/ext/visibility/visibility-2.C: Likewise.
* g++/dg/ext/visibility/visibility-3.C: Likewise.
* g++/dg/ext/visibility/visibility-4.C: Likewise.
* g++/dg/ext/visibility/visibility-5.C: Likewise.
* g++/dg/ext/visibility/visibility-6.C: Likewise.
* g++/dg/ext/visibility/visibility-7.C: Likewise.
* g++/dg/ext/visibility/visibility-8.C: New test.
* gcc.c-torture/compile/dll.x: Remove.
* gcc.dg/dll-2.c: Use dg-require-dll
* gcc.dg/visibility-10.c: New test.
* lib/gcc-dg.exp (dg-require-dll): Add Symbian to list of targets
supporting DLLs.
* testsuite/lib/scanasm.exp (scan_hidden): New function.
(scan_not_hidden): Likewise.
From-SVN: r85621
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 77 |
1 files changed, 76 insertions, 1 deletions
@@ -2887,7 +2887,7 @@ merge_decl_attributes (tree olddecl, tree newdecl) DECL_ATTRIBUTES (newdecl)); } -#ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES +#if TARGET_DLLIMPORT_DECL_ATTRIBUTES /* Specialization of merge_decl_attributes for various Windows targets. @@ -2940,6 +2940,81 @@ merge_dllimport_decl_attributes (tree old, tree new) return a; } +/* Handle a "dllimport" or "dllexport" attribute; arguments as in + struct attribute_spec.handler. */ + +tree +handle_dll_attribute (tree * pnode, tree name, tree args, int flags, + bool *no_add_attrs) +{ + tree node = *pnode; + + /* These attributes may apply to structure and union types being created, + but otherwise should pass to the declaration involved. */ + if (!DECL_P (node)) + { + if (flags & ((int) ATTR_FLAG_DECL_NEXT | (int) ATTR_FLAG_FUNCTION_NEXT + | (int) ATTR_FLAG_ARRAY_NEXT)) + { + *no_add_attrs = true; + return tree_cons (name, args, NULL_TREE); + } + if (TREE_CODE (node) != RECORD_TYPE && TREE_CODE (node) != UNION_TYPE) + { + warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name)); + *no_add_attrs = true; + } + + return NULL_TREE; + } + + /* Report error on dllimport ambiguities seen now before they cause + any damage. */ + if (is_attribute_p ("dllimport", name)) + { + /* Like MS, treat definition of dllimported variables and + non-inlined functions on declaration as syntax errors. We + allow the attribute for function definitions if declared + inline. */ + if (TREE_CODE (node) == FUNCTION_DECL && DECL_INITIAL (node) + && !DECL_DECLARED_INLINE_P (node)) + { + error ("%Jfunction `%D' definition is marked dllimport.", node, node); + *no_add_attrs = true; + } + + else if (TREE_CODE (node) == VAR_DECL) + { + if (DECL_INITIAL (node)) + { + error ("%Jvariable `%D' definition is marked dllimport.", + node, node); + *no_add_attrs = true; + } + + /* `extern' needn't be specified with dllimport. + Specify `extern' now and hope for the best. Sigh. */ + DECL_EXTERNAL (node) = 1; + /* Also, implicitly give dllimport'd variables declared within + a function global scope, unless declared static. */ + if (current_function_decl != NULL_TREE && !TREE_STATIC (node)) + TREE_PUBLIC (node) = 1; + } + } + + /* Report error if symbol is not accessible at global scope. */ + if (!TREE_PUBLIC (node) + && (TREE_CODE (node) == VAR_DECL + || TREE_CODE (node) == FUNCTION_DECL)) + { + error ("%Jexternal linkage required for symbol '%D' because of " + "'%s' attribute.", node, node, IDENTIFIER_POINTER (name)); + *no_add_attrs = true; + } + + return NULL_TREE; +} + #endif /* TARGET_DLLIMPORT_DECL_ATTRIBUTES */ /* Set the type qualifiers for TYPE to TYPE_QUALS, which is a bitmask |