Comments
Patch
commit ff67fd57b978582fcc5f8818a8192a25c507ac34
Author: Jason Merrill <jason@redhat.com>
Date: Wed Sep 15 16:07:37 2010 -0400
* semantics.c (finish_id_expression): Diagnose use of function
parms in evaluated context outside function body.
@@ -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,
new file mode 100644
@@ -0,0 +1 @@
+void f (int i, int p[i]); // { dg-error "use of parameter .i. outside function body" }