Commit 5a706c32 by Jason Merrill Committed by Jason Merrill

re PR c++/54420 (Segmentation fault in decl_mangling_context)

	PR c++/54420
	* cp-tree.h (LAMBDANAME_P): Remove.
	(LAMBDA_TYPE_P): Check CLASSTYPE_LAMBDA_EXPR instead.
	* cp-lang.c (cxx_dwarf_name): Likewise.
	* error.c (dump_aggr_type): Likewise.
	* semantics.c (begin_lambda_type): Set CLASSTYPE_LAMBDA_EXPR sooner.

From-SVN: r190961
parent bf30f229
2012-09-04 Jason Merrill <jason@redhat.com> 2012-09-04 Jason Merrill <jason@redhat.com>
PR c++/54420
* cp-tree.h (LAMBDANAME_P): Remove.
(LAMBDA_TYPE_P): Check CLASSTYPE_LAMBDA_EXPR instead.
* cp-lang.c (cxx_dwarf_name): Likewise.
* error.c (dump_aggr_type): Likewise.
* semantics.c (begin_lambda_type): Set CLASSTYPE_LAMBDA_EXPR sooner.
PR c++/54198 PR c++/54198
* decl.c (check_default_argument): Set cp_unevaluated_operand * decl.c (check_default_argument): Set cp_unevaluated_operand
around call to perform_implicit_conversion_flags. around call to perform_implicit_conversion_flags.
......
...@@ -115,7 +115,7 @@ cxx_dwarf_name (tree t, int verbosity) ...@@ -115,7 +115,7 @@ cxx_dwarf_name (tree t, int verbosity)
gcc_assert (DECL_P (t)); gcc_assert (DECL_P (t));
if (DECL_NAME (t) if (DECL_NAME (t)
&& (ANON_AGGRNAME_P (DECL_NAME (t)) || LAMBDANAME_P (DECL_NAME (t)))) && (ANON_AGGRNAME_P (DECL_NAME (t)) || LAMBDA_TYPE_P (t)))
return NULL; return NULL;
if (verbosity >= 2) if (verbosity >= 2)
return decl_as_dwarf_string (t, return decl_as_dwarf_string (t,
......
...@@ -621,7 +621,7 @@ struct GTY (()) tree_trait_expr { ...@@ -621,7 +621,7 @@ struct GTY (()) tree_trait_expr {
/* Based off of TYPE_ANONYMOUS_P. */ /* Based off of TYPE_ANONYMOUS_P. */
#define LAMBDA_TYPE_P(NODE) \ #define LAMBDA_TYPE_P(NODE) \
(CLASS_TYPE_P (NODE) && LAMBDANAME_P (TYPE_LINKAGE_IDENTIFIER (NODE))) (CLASS_TYPE_P (NODE) && CLASSTYPE_LAMBDA_EXPR (NODE))
/* Test if FUNCTION_DECL is a lambda function. */ /* Test if FUNCTION_DECL is a lambda function. */
#define LAMBDA_FUNCTION_P(FNDECL) \ #define LAMBDA_FUNCTION_P(FNDECL) \
...@@ -4329,10 +4329,6 @@ extern GTY(()) VEC(tree,gc) *local_classes; ...@@ -4329,10 +4329,6 @@ extern GTY(()) VEC(tree,gc) *local_classes;
#define LAMBDANAME_PREFIX "__lambda" #define LAMBDANAME_PREFIX "__lambda"
#define LAMBDANAME_FORMAT LAMBDANAME_PREFIX "%d" #define LAMBDANAME_FORMAT LAMBDANAME_PREFIX "%d"
#define LAMBDANAME_P(ID_NODE) \
(!strncmp (IDENTIFIER_POINTER (ID_NODE), \
LAMBDANAME_PREFIX, \
sizeof (LAMBDANAME_PREFIX) - 1))
#define UDLIT_OP_ANSI_PREFIX "operator\"\" " #define UDLIT_OP_ANSI_PREFIX "operator\"\" "
#define UDLIT_OP_ANSI_FORMAT UDLIT_OP_ANSI_PREFIX "%s" #define UDLIT_OP_ANSI_FORMAT UDLIT_OP_ANSI_PREFIX "%s"
......
...@@ -657,7 +657,7 @@ dump_aggr_type (tree t, int flags) ...@@ -657,7 +657,7 @@ dump_aggr_type (tree t, int flags)
else else
pp_printf (pp_base (cxx_pp), M_("<anonymous %s>"), variety); pp_printf (pp_base (cxx_pp), M_("<anonymous %s>"), variety);
} }
else if (LAMBDANAME_P (name)) else if (LAMBDA_TYPE_P (name))
{ {
/* A lambda's "type" is essentially its signature. */ /* A lambda's "type" is essentially its signature. */
pp_string (cxx_pp, M_("<lambda")); pp_string (cxx_pp, M_("<lambda"));
......
...@@ -1998,10 +1998,9 @@ make_anon_name (void) ...@@ -1998,10 +1998,9 @@ make_anon_name (void)
} }
/* This code is practically identical to that for creating /* This code is practically identical to that for creating
anonymous names, but is just used for lambdas instead. This is necessary anonymous names, but is just used for lambdas instead. This isn't really
because anonymous names are recognized and cannot be passed to template necessary, but it's convenient to avoid treating lambdas like other
functions. */ anonymous types. */
/* FIXME is this still necessary? */
static GTY(()) int lambda_cnt = 0; static GTY(()) int lambda_cnt = 0;
......
...@@ -8746,6 +8746,10 @@ begin_lambda_type (tree lambda) ...@@ -8746,6 +8746,10 @@ begin_lambda_type (tree lambda)
/* Designate it as a struct so that we can use aggregate initialization. */ /* Designate it as a struct so that we can use aggregate initialization. */
CLASSTYPE_DECLARED_CLASS (type) = false; CLASSTYPE_DECLARED_CLASS (type) = false;
/* Cross-reference the expression and the type. */
LAMBDA_EXPR_CLOSURE (lambda) = type;
CLASSTYPE_LAMBDA_EXPR (type) = lambda;
/* Clear base types. */ /* Clear base types. */
xref_basetypes (type, /*bases=*/NULL_TREE); xref_basetypes (type, /*bases=*/NULL_TREE);
...@@ -8754,10 +8758,6 @@ begin_lambda_type (tree lambda) ...@@ -8754,10 +8758,6 @@ begin_lambda_type (tree lambda)
if (type == error_mark_node) if (type == error_mark_node)
return error_mark_node; return error_mark_node;
/* Cross-reference the expression and the type. */
LAMBDA_EXPR_CLOSURE (lambda) = type;
CLASSTYPE_LAMBDA_EXPR (type) = lambda;
return type; return type;
} }
......
2012-09-04 Jason Merrill <jason@redhat.com> 2012-09-04 Jason Merrill <jason@redhat.com>
PR c++/54420
* g++.dg/cpp0x/lambda/lambda-intname.C: New.
PR c++/54198 PR c++/54198
* g++.dg/template/defarg15.C: New. * g++.dg/template/defarg15.C: New.
......
// PR c++/54420
class __lambda
{
virtual bool is_sub ();
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment