diff options
author | Mark Mitchell <mark@codesourcery.com> | 2007-06-23 19:17:04 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2007-06-23 19:17:04 +0000 |
commit | 3a687f8bbb2c222ed8752901976f638a1980e854 (patch) | |
tree | 68bf248eebd2d13665cd9f9a10d25b6810ef5803 /gcc/tree.c | |
parent | e36711f3cd476b24b011f18953aa3ed3e9a70a36 (diff) | |
download | gcc-3a687f8bbb2c222ed8752901976f638a1980e854.zip gcc-3a687f8bbb2c222ed8752901976f638a1980e854.tar.gz gcc-3a687f8bbb2c222ed8752901976f638a1980e854.tar.bz2 |
extend.texi: Document that dllimport and dllexport imply default visibility.
2007-06-23 Mark Mitchell <mark@codesourcery.com>
* doc/extend.texi: Document that dllimport and dllexport imply
default visibility.
* tree.c (handle_dll_attribute): Set DECL_VISIBILITY on the
imported or exported declaration, including type declarations.
* c-common.c (handle_visibility_attribute): Check for conflicts
with dllimport/dllexport.
(c_determine_visibility): Handle dllimport/dllexport as an
explicit visibility atttribute.
2007-06-23 Mark Mitchell <mark@codesourcery.com>
* decl2.c (determine_visibility): Don't look for dllexport here.
(determine_visibility_from_class): Tidy.
2007-06-23 Mark Mitchell <mark@codesourcery.com>
* gcc.dg/visibility-12.c: New test.
* gcc.dg/visibility-13.c: Likewise.
* g++.dg/ext/visibility-9.C: Likewise.
* g++.dg/ext/visibility-10.C: Likewise.
From-SVN: r125975
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 31 |
1 files changed, 27 insertions, 4 deletions
@@ -4001,18 +4001,25 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags, *no_add_attrs = true; return tree_cons (name, args, NULL_TREE); } - if (TREE_CODE (node) != RECORD_TYPE && TREE_CODE (node) != UNION_TYPE) + if (TREE_CODE (node) == RECORD_TYPE + || TREE_CODE (node) == UNION_TYPE) + { + node = TYPE_NAME (node); + if (!node) + return NULL_TREE; + } + else { warning (OPT_Wattributes, "%qs attribute ignored", IDENTIFIER_POINTER (name)); *no_add_attrs = true; + return NULL_TREE; } - - return NULL_TREE; } if (TREE_CODE (node) != FUNCTION_DECL - && TREE_CODE (node) != VAR_DECL) + && TREE_CODE (node) != VAR_DECL + && TREE_CODE (node) != TYPE_DECL) { *no_add_attrs = true; warning (OPT_Wattributes, "%qs attribute ignored", @@ -4075,6 +4082,22 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags, *no_add_attrs = true; } + /* A dllexport'd entity must have default visibility so that other + program units (shared libraries or the main executable) can see + it. A dllimport'd entity must have default visibility so that + the linker knows that undefined references within this program + unit can be resolved by the dynamic linker. */ + if (!*no_add_attrs) + { + if (DECL_VISIBILITY_SPECIFIED (node) + && DECL_VISIBILITY (node) != VISIBILITY_DEFAULT) + error ("%qs implies default visibility, but %qD has already " + "been declared with a different visibility", + IDENTIFIER_POINTER (name), node); + DECL_VISIBILITY (node) = VISIBILITY_DEFAULT; + DECL_VISIBILITY_SPECIFIED (node) = 1; + } + return NULL_TREE; } |