semantics.c (finish_id_expression): Diagnose use of function parms in evaluated context outside function body.

* semantics.c (finish_id_expression): Diagnose use of function
	parms in evaluated context outside function body.

From-SVN: r164322
This commit is contained in:
Jason Merrill 2010-09-15 19:55:49 -04:00 committed by Jason Merrill
parent 441b624e3d
commit da9bc840f6
4 changed files with 16 additions and 0 deletions

View File

@ -1,5 +1,8 @@
2010-09-15 Jason Merrill <jason@redhat.com>
* semantics.c (finish_id_expression): Diagnose use of function
parms in evaluated context outside function body.
* decl2.c (grokbitfield): Diagnose non-integral width.
* call.c (convert_like_real): Use the underlying type of the

View File

@ -2864,6 +2864,16 @@ finish_id_expression (tree id_expression,
return error_mark_node;
}
}
/* Also disallow uses of function parameters outside the function
body, except inside an unevaluated context (i.e. decltype). */
if (TREE_CODE (decl) == PARM_DECL
&& DECL_CONTEXT (decl) == NULL_TREE
&& !cp_unevaluated_operand)
{
error ("use of parameter %qD outside function body", decl);
return error_mark_node;
}
}
/* If we didn't find anything, or what we found was a type,

View File

@ -1,5 +1,7 @@
2010-09-15 Jason Merrill <jason@redhat.com>
* g++.dg/parse/parameter-declaration-2.C: New.
* g++.dg/cpp0x/scoped_enum2.C: New.
2010-09-15 Eric Botcazou <ebotcazou@adacore.com>

View File

@ -0,0 +1 @@
void f (int i, int p[i]); // { dg-error "use of parameter .i. outside function body" }