aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Bothner <bothner@kalessin.cygnus.com>1995-08-25 19:06:45 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1995-08-25 19:06:45 -0400
commitf3be9e3c336718ee354a5a76eff94315ee2eac9a (patch)
tree4b7c86e341883619548aa0d07456ebe6416b4b4b
parentd2ad151f7fb2ebf6685826b250e55e5038482a1c (diff)
downloadgcc-f3be9e3c336718ee354a5a76eff94315ee2eac9a.zip
gcc-f3be9e3c336718ee354a5a76eff94315ee2eac9a.tar.gz
gcc-f3be9e3c336718ee354a5a76eff94315ee2eac9a.tar.bz2
(do_identifier): Handle old (non-ANSI) for scoping, and warn if
conflicts. From-SVN: r10275
-rw-r--r--gcc/cp/lex.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 2e0997e..a99e9af 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -2916,6 +2916,41 @@ do_identifier (token)
SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl);
}
}
+
+ if (TREE_CODE (id) == VAR_DECL && DECL_DEAD_FOR_LOCAL (id))
+ {
+ tree shadowed = DECL_SHADOWED_FOR_VAR (id);
+ if (shadowed)
+ {
+ if (!DECL_ERROR_REPORTED (id))
+ {
+ warning ("name lookup of `%s' changed",
+ IDENTIFIER_POINTER (token));
+ cp_warning_at (" matches this `%D' under current ANSI rules",
+ shadowed);
+ cp_warning_at (" matches this `%D' under old rules", id);
+ DECL_ERROR_REPORTED (id) = 1;
+ }
+ id = shadowed;
+ }
+ else if (!DECL_ERROR_REPORTED (id))
+ {
+ static char msg[]
+ = "name lookup of `%s' changed for new ANSI `for' scoping";
+ DECL_ERROR_REPORTED (id) = 1;
+ if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (id)))
+ {
+ error (msg, IDENTIFIER_POINTER (token));
+ cp_error_at (" cannot use obsolete binding at `%D' because it has a destructor", id);
+ id = error_mark_node;
+ }
+ else
+ {
+ pedwarn (msg, IDENTIFIER_POINTER (token));
+ cp_pedwarn_at (" using obsolete binding at `%D'", id);
+ }
+ }
+ }
/* TREE_USED is set in `hack_identifier'. */
if (TREE_CODE (id) == CONST_DECL)
{