aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2002-06-24 19:18:43 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2002-06-24 19:18:43 +0000
commit5f261ba970a894543b1c8c30f71c7eb2a234ba93 (patch)
treebe46d82b47945fa6f5b787b66f752af4d7711a6b /gcc/cp/decl.c
parent87912be720118115eded3786b807a34cfb0f0a81 (diff)
downloadgcc-5f261ba970a894543b1c8c30f71c7eb2a234ba93.zip
gcc-5f261ba970a894543b1c8c30f71c7eb2a234ba93.tar.gz
gcc-5f261ba970a894543b1c8c30f71c7eb2a234ba93.tar.bz2
cp-tree.h (SCALAR_TYPE_P): New macro.
* cp-tree.h (SCALAR_TYPE_P): New macro. (check_for_out_of_scope_variable): New function. (at_class_scope_p): Likewise. (finish_fname): Likewise. * class.c (finish_struct): Use at_function_scope_p. * decl.c (check_for_out_of_scope_variable): New function, split out from do_identifier. (finish_enum): Use at_function_scope_p. * lex.c (do_identifier): Use check_for_out_of_scope_variable. * parse.y (VAR_FUNC_NAME): Give it <ttype>. Use finish_fname. (primary): Use at_function_scope_p. * search.c (at_class_scope_p): New function. * semantics.c (finish_fname): Likewise. (check_multiple_declarators): Use at_function_scope_p. From-SVN: r54962
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c64
1 files changed, 60 insertions, 4 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index dc75876..3a6e7a1 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5921,6 +5921,65 @@ warn_about_implicit_typename_lookup (typename, binding)
}
}
+/* Check to see whether or not DECL is a variable that would have been
+ in scope under the ARM, but is not in scope under the ANSI/ISO
+ standard. If so, issue an error message. If name lookup would
+ work in both cases, but return a different result, this function
+ returns the result of ANSI/ISO lookup. Otherwise, it returns
+ DECL. */
+
+tree
+check_for_out_of_scope_variable (tree decl)
+{
+ tree shadowed;
+
+ /* We only care about out of scope variables. */
+ if (!(TREE_CODE (decl) == VAR_DECL && DECL_DEAD_FOR_LOCAL (decl)))
+ return decl;
+
+ shadowed = DECL_SHADOWED_FOR_VAR (decl);
+ while (shadowed != NULL_TREE && TREE_CODE (shadowed) == VAR_DECL
+ && DECL_DEAD_FOR_LOCAL (shadowed))
+ shadowed = DECL_SHADOWED_FOR_VAR (shadowed);
+ if (!shadowed)
+ shadowed = IDENTIFIER_NAMESPACE_VALUE (DECL_NAME (decl));
+ if (shadowed)
+ {
+ if (!DECL_ERROR_REPORTED (decl))
+ {
+ warning ("name lookup of `%D' changed",
+ DECL_NAME (decl));
+ cp_warning_at (" matches this `%D' under ISO standard rules",
+ shadowed);
+ cp_warning_at (" matches this `%D' under old rules", decl);
+ DECL_ERROR_REPORTED (decl) = 1;
+ }
+ return shadowed;
+ }
+
+ /* If we have already complained about this declaration, there's no
+ need to do it again. */
+ if (DECL_ERROR_REPORTED (decl))
+ return decl;
+
+ DECL_ERROR_REPORTED (decl) = 1;
+ if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
+ {
+ error ("name lookup of `%D' changed for new ISO `for' scoping",
+ DECL_NAME (decl));
+ cp_error_at (" cannot use obsolete binding at `%D' because it has a destructor", decl);
+ return error_mark_node;
+ }
+ else
+ {
+ pedwarn ("name lookup of `%D' changed for new ISO `for' scoping",
+ DECL_NAME (decl));
+ cp_pedwarn_at (" using obsolete binding at `%D'", decl);
+ }
+
+ return decl;
+}
+
/* Look up NAME in the current binding level and its superiors in the
namespace of variables, functions and typedefs. Return a ..._DECL
node of some kind representing its definition if there is only one
@@ -13171,11 +13230,8 @@ finish_enum (enumtype)
postponed until the template is instantiated. */
if (processing_template_decl)
{
- tree scope = current_scope ();
- if (scope && TREE_CODE (scope) == FUNCTION_DECL)
+ if (at_function_scope_p ())
add_stmt (build_min (TAG_DEFN, enumtype));
-
-
return;
}