re PR c++/55015 (Lambda functions not found at link time when declared in an inline function)

PR c++/55015
	PR c++/53821
	* semantics.c (maybe_add_lambda_conv_op): Revert earlier change.
	* decl.c (start_preparsed_function): Make local class methods comdat
	in templates, too.

From-SVN: r194253
This commit is contained in:
Jason Merrill 2012-12-06 09:39:52 -05:00 committed by Jason Merrill
parent f626338437
commit cc52ca8920
4 changed files with 21 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2012-12-06 Jason Merrill <jason@redhat.com>
PR c++/55015
PR c++/53821
* semantics.c (maybe_add_lambda_conv_op): Revert earlier change.
* decl.c (start_preparsed_function): Make local class methods comdat
in templates, too.
2012-11-29 Jason Merrill <jason@redhat.com>
PR c++/53137

View File

@ -12928,10 +12928,9 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
if (DECL_NOT_REALLY_EXTERN (decl1))
DECL_EXTERNAL (decl1) = 0;
if (ctx != NULL_TREE && DECL_DECLARED_INLINE_P (ctx)
&& TREE_PUBLIC (ctx))
if (ctx != NULL_TREE && vague_linkage_p (ctx))
/* This is a function in a local class in an extern inline
function. */
or template function. */
comdat_linkage (decl1);
}
/* If this function belongs to an interface, it is public.

View File

@ -9311,6 +9311,8 @@ maybe_add_lambda_conv_op (tree type)
DECL_NOT_REALLY_EXTERN (fn) = 1;
DECL_DECLARED_INLINE_P (fn) = 1;
DECL_ARGUMENTS (fn) = build_this_parm (fntype, TYPE_QUAL_CONST);
if (nested)
DECL_INTERFACE_KNOWN (fn) = 1;
add_method (type, fn, NULL_TREE);
@ -9341,6 +9343,8 @@ maybe_add_lambda_conv_op (tree type)
DECL_ARGUMENTS (fn) = copy_list (DECL_CHAIN (DECL_ARGUMENTS (callop)));
for (arg = DECL_ARGUMENTS (fn); arg; arg = DECL_CHAIN (arg))
DECL_CONTEXT (arg) = fn;
if (nested)
DECL_INTERFACE_KNOWN (fn) = 1;
add_method (type, fn, NULL_TREE);

View File

@ -0,0 +1,7 @@
// PR c++/55015
// { dg-do link }
// { dg-options -std=c++11 }
typedef void (*VoidFunc)();
inline VoidFunc GetFunc() { return [](){}; }
int main() { VoidFunc func = GetFunc(); }