aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-11-07 12:51:40 -0500
committerJason Merrill <jason@gcc.gnu.org>2011-11-07 12:51:40 -0500
commit6d87092d196c96ef596c7877b40409d00af6ee7a (patch)
treee9aa9f3cd40d0c2eafea7c00b8df253911a81565 /gcc/cp/decl2.c
parentc7e6757f2a0c3c391bd71d4ddb85843170377ce5 (diff)
downloadgcc-6d87092d196c96ef596c7877b40409d00af6ee7a.zip
gcc-6d87092d196c96ef596c7877b40409d00af6ee7a.tar.gz
gcc-6d87092d196c96ef596c7877b40409d00af6ee7a.tar.bz2
re PR c++/35688 (template visibility not overridden by template arguments)
PR c++/35688 * decl2.c (constrain_visibility): Return void. Add tmpl parm which gives the constraint priority over an attribute. (constrain_visibility_for_template, determine_visibility): Adjust. * pt.c (instantiate_class_template_1): Call determine_visibility. From-SVN: r181102
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 80fb0c3..17be3ad 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1954,10 +1954,12 @@ type_visibility (tree type)
}
/* Limit the visibility of DECL to VISIBILITY, if not explicitly
- specified (or if VISIBILITY is static). */
+ specified (or if VISIBILITY is static). If TMPL is true, this
+ constraint is for a template argument, and takes precedence
+ over explicitly-specified visibility on the template. */
-static bool
-constrain_visibility (tree decl, int visibility)
+static void
+constrain_visibility (tree decl, int visibility, bool tmpl)
{
if (visibility == VISIBILITY_ANON)
{
@@ -1974,16 +1976,11 @@ constrain_visibility (tree decl, int visibility)
DECL_NOT_REALLY_EXTERN (decl) = 1;
}
}
- /* We check decl_has_visibility_attr rather than
- DECL_VISIBILITY_SPECIFIED here because we want other considerations
- to override visibility from a namespace or #pragma. */
else if (visibility > DECL_VISIBILITY (decl)
- && !decl_has_visibility_attr (decl))
+ && (tmpl || !DECL_VISIBILITY_SPECIFIED (decl)))
{
DECL_VISIBILITY (decl) = (enum symbol_visibility) visibility;
- return true;
}
- return false;
}
/* Constrain the visibility of DECL based on the visibility of its template
@@ -2019,7 +2016,7 @@ constrain_visibility_for_template (tree decl, tree targs)
}
}
if (vis)
- constrain_visibility (decl, vis);
+ constrain_visibility (decl, vis, true);
}
}
@@ -2132,7 +2129,7 @@ determine_visibility (tree decl)
if (underlying_vis == VISIBILITY_ANON
|| (CLASS_TYPE_P (underlying_type)
&& CLASSTYPE_VISIBILITY_SPECIFIED (underlying_type)))
- constrain_visibility (decl, underlying_vis);
+ constrain_visibility (decl, underlying_vis, false);
else
DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
}
@@ -2140,7 +2137,7 @@ determine_visibility (tree decl)
{
/* tinfo visibility is based on the type it's for. */
constrain_visibility
- (decl, type_visibility (TREE_TYPE (DECL_NAME (decl))));
+ (decl, type_visibility (TREE_TYPE (DECL_NAME (decl))), false);
/* Give the target a chance to override the visibility associated
with DECL. */
@@ -2207,14 +2204,14 @@ determine_visibility (tree decl)
if (decl_anon_ns_mem_p (decl))
/* Names in an anonymous namespace get internal linkage.
This might change once we implement export. */
- constrain_visibility (decl, VISIBILITY_ANON);
+ constrain_visibility (decl, VISIBILITY_ANON, false);
else if (TREE_CODE (decl) != TYPE_DECL)
{
/* Propagate anonymity from type to decl. */
int tvis = type_visibility (TREE_TYPE (decl));
if (tvis == VISIBILITY_ANON
|| ! DECL_VISIBILITY_SPECIFIED (decl))
- constrain_visibility (decl, tvis);
+ constrain_visibility (decl, tvis, false);
}
else if (no_linkage_check (TREE_TYPE (decl), /*relaxed_p=*/true))
/* DR 757: A type without linkage shall not be used as the type of a
@@ -2225,7 +2222,7 @@ determine_visibility (tree decl)
Since non-extern "C" decls need to be defined in the same
translation unit, we can make the type internal. */
- constrain_visibility (decl, VISIBILITY_ANON);
+ constrain_visibility (decl, VISIBILITY_ANON, false);
/* If visibility changed and DECL already has DECL_RTL, ensure
symbol flags are updated. */