aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2007-06-23 19:17:04 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2007-06-23 19:17:04 +0000
commit3a687f8bbb2c222ed8752901976f638a1980e854 (patch)
tree68bf248eebd2d13665cd9f9a10d25b6810ef5803 /gcc/tree.c
parente36711f3cd476b24b011f18953aa3ed3e9a70a36 (diff)
downloadgcc-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.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 45e53cc..f70a3073 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -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;
}