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/c-common.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/c-common.c')
-rw-r--r-- | gcc/c-common.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 9bad32d..e1c3875 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -5419,11 +5419,22 @@ handle_visibility_attribute (tree *node, tree name, tree args, } if (DECL_VISIBILITY_SPECIFIED (decl) - && vis != DECL_VISIBILITY (decl) - && lookup_attribute ("visibility", (TYPE_P (*node) - ? TYPE_ATTRIBUTES (*node) - : DECL_ATTRIBUTES (decl)))) - error ("%qD redeclared with different visibility", decl); + && vis != DECL_VISIBILITY (decl)) + { + tree attributes = (TYPE_P (*node) + ? TYPE_ATTRIBUTES (*node) + : DECL_ATTRIBUTES (decl)); + if (lookup_attribute ("visibility", attributes)) + error ("%qD redeclared with different visibility", decl); + else if (TARGET_DLLIMPORT_DECL_ATTRIBUTES + && lookup_attribute ("dllimport", attributes)) + error ("%qD was declared %qs which implies default visibility", + decl, "dllimport"); + else if (TARGET_DLLIMPORT_DECL_ATTRIBUTES + && lookup_attribute ("dllexport", attributes)) + error ("%qD was declared %qs which implies default visibility", + decl, "dllexport"); + } DECL_VISIBILITY (decl) = vis; DECL_VISIBILITY_SPECIFIED (decl) = 1; @@ -5456,18 +5467,12 @@ c_determine_visibility (tree decl) to distinguish the use of an attribute from the use of a "#pragma GCC visibility push(...)"; in the latter case we still want other considerations to be able to overrule the #pragma. */ - if (lookup_attribute ("visibility", DECL_ATTRIBUTES (decl))) + if (lookup_attribute ("visibility", DECL_ATTRIBUTES (decl)) + || (TARGET_DLLIMPORT_DECL_ATTRIBUTES + && (lookup_attribute ("dllimport", DECL_ATTRIBUTES (decl)) + || lookup_attribute ("dllexport", DECL_ATTRIBUTES (decl))))) return true; - /* Anything that is exported must have default visibility. */ - if (TARGET_DLLIMPORT_DECL_ATTRIBUTES - && lookup_attribute ("dllexport", DECL_ATTRIBUTES (decl))) - { - DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT; - DECL_VISIBILITY_SPECIFIED (decl) = 1; - return true; - } - /* Set default visibility to whatever the user supplied with visibility_specified depending on #pragma GCC visibility. */ if (!DECL_VISIBILITY_SPECIFIED (decl)) |