PR c++/85646 - lambda visibility.
* decl2.c (determine_visibility): Don't mess with template arguments from the containing scope. (vague_linkage_p): Check DECL_ABSTRACT_P before looking at a 'tor thunk. From-SVN: r260017
This commit is contained in:
parent
ee336e846d
commit
6b83a3c6e3
3 changed files with 29 additions and 17 deletions
|
@ -1,3 +1,11 @@
|
|||
2018-05-07 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/85646 - lambda visibility.
|
||||
* decl2.c (determine_visibility): Don't mess with template arguments
|
||||
from the containing scope.
|
||||
(vague_linkage_p): Check DECL_ABSTRACT_P before looking at a 'tor
|
||||
thunk.
|
||||
|
||||
2018-05-07 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
Remove fno-for-scope
|
||||
|
|
|
@ -1939,10 +1939,13 @@ vague_linkage_p (tree decl)
|
|||
{
|
||||
if (!TREE_PUBLIC (decl))
|
||||
{
|
||||
/* maybe_thunk_body clears TREE_PUBLIC on the maybe-in-charge 'tor
|
||||
variants, check one of the "clones" for the real linkage. */
|
||||
/* maybe_thunk_body clears TREE_PUBLIC and DECL_ABSTRACT_P on the
|
||||
maybe-in-charge 'tor variants; in that case we need to check one of
|
||||
the "clones" for the real linkage. But only in that case; before
|
||||
maybe_clone_body we haven't yet copied the linkage to the clones. */
|
||||
if ((DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl)
|
||||
|| DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl))
|
||||
&& !DECL_ABSTRACT_P (decl)
|
||||
&& DECL_CHAIN (decl)
|
||||
&& DECL_CLONED_FUNCTION_P (DECL_CHAIN (decl)))
|
||||
return vague_linkage_p (DECL_CHAIN (decl));
|
||||
|
@ -2422,21 +2425,8 @@ determine_visibility (tree decl)
|
|||
}
|
||||
|
||||
/* Local classes in templates have CLASSTYPE_USE_TEMPLATE set,
|
||||
but have no TEMPLATE_INFO. Their containing template
|
||||
function does, and the local class could be constrained
|
||||
by that. */
|
||||
if (DECL_LANG_SPECIFIC (fn) && DECL_USE_TEMPLATE (fn))
|
||||
template_decl = fn;
|
||||
else if (template_decl)
|
||||
{
|
||||
/* FN must be a regenerated lambda function, since they don't
|
||||
have template arguments. Find a containing non-lambda
|
||||
template instantiation. */
|
||||
tree ctx = fn;
|
||||
while (ctx && !get_template_info (ctx))
|
||||
ctx = get_containing_scope (ctx);
|
||||
template_decl = ctx;
|
||||
}
|
||||
but have no TEMPLATE_INFO, so don't try to check it. */
|
||||
template_decl = NULL_TREE;
|
||||
}
|
||||
else if (VAR_P (decl) && DECL_TINFO_P (decl)
|
||||
&& flag_visibility_ms_compat)
|
||||
|
|
14
gcc/testsuite/g++.dg/ext/visibility/lambda1.C
Normal file
14
gcc/testsuite/g++.dg/ext/visibility/lambda1.C
Normal file
|
@ -0,0 +1,14 @@
|
|||
// PR c++/85646
|
||||
// { dg-do compile { target c++11 } }
|
||||
// { dg-additional-options -fvisibility=hidden }
|
||||
|
||||
template<typename T>
|
||||
void foo() {
|
||||
struct inner {
|
||||
inner() {
|
||||
(void)([this] { });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int main() { foo<int>(); }
|
Loading…
Add table
Reference in a new issue