aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-04-20 15:18:52 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-04-20 15:18:52 +0000
commit7d8bd4f888867472c68cec4d25b3b47817509ecd (patch)
treeb6a900e9e079def1150529fe776c6e7fc4601abb /gcc/cp/semantics.c
parente6f8842c079cc138e95dd3732b58f13e05bcc4c2 (diff)
svn merge -r107806:112661 svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-3_4-branchredhat/gcc-3_4-branch
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/redhat/gcc-3_4-branch@113116 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 55984b75ade..943e7a1a92a 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2400,6 +2400,21 @@ finish_id_expression (tree id_expression,
was entirely defined. */
if (!scope && decl != error_mark_node)
maybe_note_name_used_in_class (id_expression, decl);
+
+ /* Disallow uses of local variables from containing functions. */
+ if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL)
+ {
+ tree context = decl_function_context (decl);
+ if (context != NULL_TREE && context != current_function_decl
+ && ! TREE_STATIC (decl))
+ {
+ error (TREE_CODE (decl) == VAR_DECL
+ ? "use of `auto' variable from containing function"
+ : "use of parameter from containing function");
+ cp_error_at (" `%#D' declared here", decl);
+ return error_mark_node;
+ }
+ }
}
/* If we didn't find anything, or what we found was a type,
@@ -2666,23 +2681,6 @@ finish_id_expression (tree id_expression,
}
else
{
- if (TREE_CODE (decl) == VAR_DECL
- || TREE_CODE (decl) == PARM_DECL
- || TREE_CODE (decl) == RESULT_DECL)
- {
- tree context = decl_function_context (decl);
-
- if (context != NULL_TREE && context != current_function_decl
- && ! TREE_STATIC (decl))
- {
- error ("use of %s from containing function",
- (TREE_CODE (decl) == VAR_DECL
- ? "`auto' variable" : "parameter"));
- cp_error_at (" `%#D' declared here", decl);
- return error_mark_node;
- }
- }
-
if (DECL_P (decl) && DECL_NONLOCAL (decl)
&& DECL_CLASS_SCOPE_P (decl)
&& DECL_CONTEXT (decl) != current_class_type)