re PR c++/60185 (ICE with invalid default parameter)
PR c++/60185 * parser.c (cp_parser_default_argument): Clear current_class_ptr/current_class_ref like tsubst_default_argument. From-SVN: r208029
This commit is contained in:
parent
e7b67047c7
commit
c754ffcc4c
4 changed files with 31 additions and 2 deletions
|
@ -1,5 +1,9 @@
|
|||
2014-02-21 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/60185
|
||||
* parser.c (cp_parser_default_argument): Clear
|
||||
current_class_ptr/current_class_ref like tsubst_default_argument.
|
||||
|
||||
PR c++/60252
|
||||
* lambda.c (maybe_resolve_dummy): Check lambda_function rather
|
||||
than current_binding_level.
|
||||
|
|
|
@ -18633,8 +18633,24 @@ cp_parser_default_argument (cp_parser *parser, bool template_parm_p)
|
|||
/* Parse the assignment-expression. */
|
||||
if (template_parm_p)
|
||||
push_deferring_access_checks (dk_no_deferred);
|
||||
tree saved_class_ptr = NULL_TREE;
|
||||
tree saved_class_ref = NULL_TREE;
|
||||
/* The "this" pointer is not valid in a default argument. */
|
||||
if (cfun)
|
||||
{
|
||||
saved_class_ptr = current_class_ptr;
|
||||
cp_function_chain->x_current_class_ptr = NULL_TREE;
|
||||
saved_class_ref = current_class_ref;
|
||||
cp_function_chain->x_current_class_ref = NULL_TREE;
|
||||
}
|
||||
default_argument
|
||||
= cp_parser_initializer (parser, &is_direct_init, &non_constant_p);
|
||||
/* Restore the "this" pointer. */
|
||||
if (cfun)
|
||||
{
|
||||
cp_function_chain->x_current_class_ptr = saved_class_ptr;
|
||||
cp_function_chain->x_current_class_ref = saved_class_ref;
|
||||
}
|
||||
if (BRACE_ENCLOSED_INITIALIZER_P (default_argument))
|
||||
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
|
||||
if (template_parm_p)
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
struct A
|
||||
{
|
||||
int i;
|
||||
A() { void foo(int=i); } // { dg-error "this" }
|
||||
int i; // { dg-message "" }
|
||||
A() { void foo(int=i); } // { dg-error "" }
|
||||
};
|
||||
|
|
9
gcc/testsuite/g++.dg/template/defarg17.C
Normal file
9
gcc/testsuite/g++.dg/template/defarg17.C
Normal file
|
@ -0,0 +1,9 @@
|
|||
// PR c++/60185
|
||||
|
||||
template<int> struct A
|
||||
{
|
||||
int i; // { dg-message "" }
|
||||
A() { void foo(int=i); } // { dg-error "" }
|
||||
};
|
||||
|
||||
A<0> a;
|
Loading…
Add table
Reference in a new issue