diff options
Diffstat (limited to 'gcc/cp/decl.c')
| -rw-r--r-- | gcc/cp/decl.c | 64 |
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; } |
