Commit da9bc840 by Jason Merrill Committed by Jason Merrill

semantics.c (finish_id_expression): Diagnose use of function parms in evaluated…

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
parent 441b624e
2010-09-15 Jason Merrill <jason@redhat.com> 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. * decl2.c (grokbitfield): Diagnose non-integral width.
* call.c (convert_like_real): Use the underlying type of the * call.c (convert_like_real): Use the underlying type of the
......
...@@ -2864,6 +2864,16 @@ finish_id_expression (tree id_expression, ...@@ -2864,6 +2864,16 @@ finish_id_expression (tree id_expression,
return error_mark_node; 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, /* If we didn't find anything, or what we found was a type,
......
2010-09-15 Jason Merrill <jason@redhat.com> 2010-09-15 Jason Merrill <jason@redhat.com>
* g++.dg/parse/parameter-declaration-2.C: New.
* g++.dg/cpp0x/scoped_enum2.C: New. * g++.dg/cpp0x/scoped_enum2.C: New.
2010-09-15 Eric Botcazou <ebotcazou@adacore.com> 2010-09-15 Eric Botcazou <ebotcazou@adacore.com>
......
void f (int i, int p[i]); // { dg-error "use of parameter .i. outside function body" }
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