[C++ PATCH] Kill -fno-for-scope
https://gcc.gnu.org/ml/gcc-patches/2018-05/msg00299.html gcc/cp/ Remove fno-for-scope * cp-tree.h (DECL_ERROR_REPORTED, DECL_DEAD_FOR_LOCAL) (DECL_HAS_SHADOWED_FOR_VAR_P, DECL_SHADOWED_FOR_VAR) (SET_DECL_SHADOWED_FOR_VAR): Delete. (decl_shadowed_for_var_lookup, decl_shadowed_for_var_insert) (check_for_out_of_scope_variable, init_shadowed_var_for_decl): Don't declare. * name-lookup.h (struct cp_binding_level): Remove dead_vars_from_for field. * cp-lang.c (cp_init_ts): Delete. (LANG_HOOKS_INIT_TS): Override to cp_common_init_ts. * cp-objcp-common.c (shadowed_var_for_decl): Delete. (decl_shadowed_for_var_lookup, decl_shadowed_for_var_insert) (init_shadowed_var_for_decl): Delete. * decl.c (poplevel): Remove shadowed for var handling. (cxx_init_decl_processing): Remove -ffor-scope deprecation. * name-lookup.c (find_local_binding): Remove shadowed for var handling. (check_local_shadow): Likewise. (check_for_out_of_scope_variable): Delete. * parser.c (cp_parser_primary_expression): Remove shadowed for var handling. * pt.c (tsubst_decl): Remove DECL_DEAD_FOR_LOCAL setting. * semantics.c (begin_for_scope): Always have a scope. (begin_for_stmt, finish_for_stmt): Remove ARM-for scope handling. (begin_range_for_stmt, finish_id_expression): Likewise. gcc/ * doc/invoke.texi (C++ Dialect Options): Remove -ffor-scope. * doc/extend.texi (Deprecated Features): Remove -fno-for-scope (Backwards Compatibility): Likewise. c-family/ * c.opt (ffor-scope): Remove functionality, issue warning. gcc/objcp/ * objcp-lang.c (objcxx_init_ts): Don't call init_shadowed_var_for_decl. gcc/testsuite/ * g++.dg/cpp0x/range-for10.C: Delete. * g++.dg/ext/forscope1.C: Delete. * g++.dg/ext/forscope2.C: Delete. * g++.dg/template/for1.C: Delete. From-SVN: r260015
This commit is contained in:
parent
1d473b8b9d
commit
ee336e846d
|
@ -1,3 +1,9 @@
|
|||
2018-05-07 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
* doc/invoke.texi (C++ Dialect Options): Remove -ffor-scope.
|
||||
* doc/extend.texi (Deprecated Features): Remove -fno-for-scope
|
||||
(Backwards Compatibility): Likewise.
|
||||
|
||||
2018-05-07 Luis Machado <luis.machado@linaro.org>
|
||||
|
||||
PR bootstrap/85681
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2018-05-07 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
* c.opt (ffor-scope): Remove functionality, issue warning.
|
||||
|
||||
2018-05-03 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
* c.opt (ffriend-injection): Remove functionality, issue warning.
|
||||
|
|
|
@ -1441,8 +1441,7 @@ fexternal-templates
|
|||
C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
|
||||
|
||||
ffor-scope
|
||||
C++ ObjC++ Var(flag_new_for_scope) Init(1)
|
||||
Scope of for-init-statement variables is local to the loop.
|
||||
C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
|
||||
|
||||
ffreestanding
|
||||
C ObjC C++ ObjC++
|
||||
|
|
|
@ -1,3 +1,32 @@
|
|||
2018-05-07 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
Remove fno-for-scope
|
||||
* cp-tree.h (DECL_ERROR_REPORTED, DECL_DEAD_FOR_LOCAL)
|
||||
(DECL_HAS_SHADOWED_FOR_VAR_P, DECL_SHADOWED_FOR_VAR)
|
||||
(SET_DECL_SHADOWED_FOR_VAR): Delete.
|
||||
(decl_shadowed_for_var_lookup, decl_shadowed_for_var_insert)
|
||||
(check_for_out_of_scope_variable, init_shadowed_var_for_decl):
|
||||
Don't declare.
|
||||
* name-lookup.h (struct cp_binding_level): Remove
|
||||
dead_vars_from_for field.
|
||||
* cp-lang.c (cp_init_ts): Delete.
|
||||
(LANG_HOOKS_INIT_TS): Override to cp_common_init_ts.
|
||||
* cp-objcp-common.c (shadowed_var_for_decl): Delete.
|
||||
(decl_shadowed_for_var_lookup, decl_shadowed_for_var_insert)
|
||||
(init_shadowed_var_for_decl): Delete.
|
||||
* decl.c (poplevel): Remove shadowed for var handling.
|
||||
(cxx_init_decl_processing): Remove -ffor-scope deprecation.
|
||||
* name-lookup.c (find_local_binding): Remove shadowed for var
|
||||
handling.
|
||||
(check_local_shadow): Likewise.
|
||||
(check_for_out_of_scope_variable): Delete.
|
||||
* parser.c (cp_parser_primary_expression): Remove shadowed for var
|
||||
handling.
|
||||
* pt.c (tsubst_decl): Remove DECL_DEAD_FOR_LOCAL setting.
|
||||
* semantics.c (begin_for_scope): Always have a scope.
|
||||
(begin_for_stmt, finish_for_stmt): Remove ARM-for scope handling.
|
||||
(begin_range_for_stmt, finish_id_expression): Likewise.
|
||||
|
||||
2018-05-07 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/85618 - ICE with initialized VLA.
|
||||
|
|
|
@ -28,7 +28,6 @@ along with GCC; see the file COPYING3. If not see
|
|||
#include "cp-objcp-common.h"
|
||||
|
||||
enum c_language_kind c_language = clk_cxx;
|
||||
static void cp_init_ts (void);
|
||||
static const char * cxx_dwarf_name (tree t, int verbosity);
|
||||
static enum classify_record cp_classify_record (tree type);
|
||||
static tree cp_eh_personality (void);
|
||||
|
@ -71,7 +70,7 @@ static tree cxx_enum_underlying_base_type (const_tree);
|
|||
#undef LANG_HOOKS_DWARF_NAME
|
||||
#define LANG_HOOKS_DWARF_NAME cxx_dwarf_name
|
||||
#undef LANG_HOOKS_INIT_TS
|
||||
#define LANG_HOOKS_INIT_TS cp_init_ts
|
||||
#define LANG_HOOKS_INIT_TS cp_common_init_ts
|
||||
#undef LANG_HOOKS_EH_PERSONALITY
|
||||
#define LANG_HOOKS_EH_PERSONALITY cp_eh_personality
|
||||
#undef LANG_HOOKS_EH_RUNTIME_TYPE
|
||||
|
@ -102,14 +101,6 @@ objcp_tsubst_copy_and_build (tree /*t*/,
|
|||
return NULL_TREE;
|
||||
}
|
||||
|
||||
static void
|
||||
cp_init_ts (void)
|
||||
{
|
||||
cp_common_init_ts ();
|
||||
|
||||
init_shadowed_var_for_decl ();
|
||||
}
|
||||
|
||||
static const char *
|
||||
cxx_dwarf_name (tree t, int verbosity)
|
||||
{
|
||||
|
|
|
@ -298,43 +298,6 @@ has_c_linkage (const_tree decl)
|
|||
return DECL_EXTERN_C_P (decl);
|
||||
}
|
||||
|
||||
static GTY ((cache))
|
||||
hash_table<tree_decl_map_cache_hasher> *shadowed_var_for_decl;
|
||||
|
||||
/* Lookup a shadowed var for FROM, and return it if we find one. */
|
||||
|
||||
tree
|
||||
decl_shadowed_for_var_lookup (tree from)
|
||||
{
|
||||
struct tree_decl_map *h, in;
|
||||
in.base.from = from;
|
||||
|
||||
h = shadowed_var_for_decl->find_with_hash (&in, DECL_UID (from));
|
||||
if (h)
|
||||
return h->to;
|
||||
return NULL_TREE;
|
||||
}
|
||||
|
||||
/* Insert a mapping FROM->TO in the shadowed var hashtable. */
|
||||
|
||||
void
|
||||
decl_shadowed_for_var_insert (tree from, tree to)
|
||||
{
|
||||
struct tree_decl_map *h;
|
||||
|
||||
h = ggc_alloc<tree_decl_map> ();
|
||||
h->base.from = from;
|
||||
h->to = to;
|
||||
*shadowed_var_for_decl->find_slot_with_hash (h, DECL_UID (from), INSERT) = h;
|
||||
}
|
||||
|
||||
void
|
||||
init_shadowed_var_for_decl (void)
|
||||
{
|
||||
shadowed_var_for_decl
|
||||
= hash_table<tree_decl_map_cache_hasher>::create_ggc (512);
|
||||
}
|
||||
|
||||
/* Return true if stmt can fall through. Used by block_may_fallthru
|
||||
default case. */
|
||||
|
||||
|
|
|
@ -447,8 +447,7 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
|
|||
6: TYPE_DEPENDENT_P_VALID
|
||||
|
||||
Usage of DECL_LANG_FLAG_?:
|
||||
0: DECL_ERROR_REPORTED (in VAR_DECL).
|
||||
DECL_TEMPLATE_PARM_P (in PARM_DECL, CONST_DECL, TYPE_DECL, or TEMPLATE_DECL)
|
||||
0: DECL_TEMPLATE_PARM_P (in PARM_DECL, CONST_DECL, TYPE_DECL, or TEMPLATE_DECL)
|
||||
DECL_LOCAL_FUNCTION_P (in FUNCTION_DECL)
|
||||
DECL_MUTABLE_P (in FIELD_DECL)
|
||||
DECL_DEPENDENT_P (in USING_DECL)
|
||||
|
@ -475,8 +474,7 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
|
|||
6: DECL_THIS_STATIC (in VAR_DECL or FUNCTION_DECL).
|
||||
DECL_FIELD_IS_BASE (in FIELD_DECL)
|
||||
TYPE_DECL_ALIAS_P (in TYPE_DECL)
|
||||
7: DECL_DEAD_FOR_LOCAL (in VAR_DECL).
|
||||
DECL_THUNK_P (in a member FUNCTION_DECL)
|
||||
7: DECL_THUNK_P (in a member FUNCTION_DECL)
|
||||
DECL_NORMAL_CAPTURE_P (in FIELD_DECL)
|
||||
8: DECL_DECLARED_CONSTEXPR_P (in VAR_DECL, FUNCTION_DECL)
|
||||
|
||||
|
@ -3212,9 +3210,6 @@ struct GTY(()) lang_decl {
|
|||
was inherited from a template parameter, not explicitly indicated. */
|
||||
#define ABI_TAG_IMPLICIT(NODE) TREE_LANG_FLAG_0 (TREE_LIST_CHECK (NODE))
|
||||
|
||||
extern tree decl_shadowed_for_var_lookup (tree);
|
||||
extern void decl_shadowed_for_var_insert (tree, tree);
|
||||
|
||||
/* Non zero if this is a using decl for a dependent scope. */
|
||||
#define DECL_DEPENDENT_P(NODE) DECL_LANG_FLAG_0 (USING_DECL_CHECK (NODE))
|
||||
|
||||
|
@ -3227,19 +3222,6 @@ extern void decl_shadowed_for_var_insert (tree, tree);
|
|||
/* Non zero if the using decl refers to a dependent type. */
|
||||
#define USING_DECL_TYPENAME_P(NODE) DECL_LANG_FLAG_1 (USING_DECL_CHECK (NODE))
|
||||
|
||||
/* In a VAR_DECL, true if we have a shadowed local variable
|
||||
in the shadowed var table for this VAR_DECL. */
|
||||
#define DECL_HAS_SHADOWED_FOR_VAR_P(NODE) \
|
||||
(VAR_DECL_CHECK (NODE)->decl_with_vis.shadowed_for_var_p)
|
||||
|
||||
/* In a VAR_DECL for a variable declared in a for statement,
|
||||
this is the shadowed (local) variable. */
|
||||
#define DECL_SHADOWED_FOR_VAR(NODE) \
|
||||
(DECL_HAS_SHADOWED_FOR_VAR_P(NODE) ? decl_shadowed_for_var_lookup (NODE) : NULL)
|
||||
|
||||
#define SET_DECL_SHADOWED_FOR_VAR(NODE, VAL) \
|
||||
(decl_shadowed_for_var_insert (NODE, VAL))
|
||||
|
||||
/* In a FUNCTION_DECL, this is nonzero if this function was defined in
|
||||
the class definition. We have saved away the text of the function,
|
||||
but have not yet processed it. */
|
||||
|
@ -3844,14 +3826,6 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
|
|||
#define TYPE_CONTAINS_VPTR_P(NODE) \
|
||||
(TYPE_POLYMORPHIC_P (NODE) || CLASSTYPE_VBASECLASSES (NODE))
|
||||
|
||||
/* This flag is true of a local VAR_DECL if it was declared in a for
|
||||
statement, but we are no longer in the scope of the for. */
|
||||
#define DECL_DEAD_FOR_LOCAL(NODE) DECL_LANG_FLAG_7 (VAR_DECL_CHECK (NODE))
|
||||
|
||||
/* This flag is set on a VAR_DECL that is a DECL_DEAD_FOR_LOCAL
|
||||
if we already emitted a warning about using it. */
|
||||
#define DECL_ERROR_REPORTED(NODE) DECL_LANG_FLAG_0 (VAR_DECL_CHECK (NODE))
|
||||
|
||||
/* Nonzero if NODE is a FUNCTION_DECL (for a function with global
|
||||
scope) declared in a local scope. */
|
||||
#define DECL_LOCAL_FUNCTION_P(NODE) \
|
||||
|
@ -6232,7 +6206,6 @@ extern tree strip_fnptr_conv (tree);
|
|||
/* in name-lookup.c */
|
||||
extern void maybe_push_cleanup_level (tree);
|
||||
extern tree make_anon_name (void);
|
||||
extern tree check_for_out_of_scope_variable (tree);
|
||||
extern tree maybe_push_decl (tree);
|
||||
extern tree current_decl_namespace (void);
|
||||
|
||||
|
@ -7403,7 +7376,6 @@ extern size_t cp_tree_size (enum tree_code);
|
|||
extern bool cp_var_mod_type_p (tree, tree);
|
||||
extern void cxx_initialize_diagnostics (diagnostic_context *);
|
||||
extern int cxx_types_compatible_p (tree, tree);
|
||||
extern void init_shadowed_var_for_decl (void);
|
||||
extern bool cxx_block_may_fallthru (const_tree);
|
||||
|
||||
/* in cp-gimplify.c */
|
||||
|
|
|
@ -576,9 +576,7 @@ poplevel (int keep, int reverse, int functionbody)
|
|||
tree subblocks;
|
||||
tree block;
|
||||
tree decl;
|
||||
int leaving_for_scope;
|
||||
scope_kind kind;
|
||||
unsigned ix;
|
||||
|
||||
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
|
||||
restart:
|
||||
|
@ -639,12 +637,6 @@ poplevel (int keep, int reverse, int functionbody)
|
|||
for (link = subblocks; link; link = BLOCK_CHAIN (link))
|
||||
BLOCK_SUPERCONTEXT (link) = block;
|
||||
|
||||
/* We still support the old for-scope rules, whereby the variables
|
||||
in a init statement were in scope after the for-statement ended.
|
||||
We only use the new rules if flag_new_for_scope is nonzero. */
|
||||
leaving_for_scope
|
||||
= current_binding_level->kind == sk_for && flag_new_for_scope;
|
||||
|
||||
/* Before we remove the declarations first check for unused variables. */
|
||||
if ((warn_unused_variable || warn_unused_but_set_variable)
|
||||
&& current_binding_level->kind != sk_template_parms
|
||||
|
@ -704,71 +696,6 @@ poplevel (int keep, int reverse, int functionbody)
|
|||
decl = TREE_CODE (link) == TREE_LIST ? TREE_VALUE (link) : link;
|
||||
tree name = OVL_NAME (decl);
|
||||
|
||||
if (leaving_for_scope && VAR_P (decl)
|
||||
/* It's hard to make this ARM compatibility hack play nicely with
|
||||
lambdas, and it really isn't necessary in C++11 mode. */
|
||||
&& cxx_dialect < cxx11
|
||||
&& name)
|
||||
{
|
||||
cxx_binding *ob = outer_binding (name,
|
||||
IDENTIFIER_BINDING (name),
|
||||
/*class_p=*/true);
|
||||
tree ns_binding = NULL_TREE;
|
||||
if (!ob)
|
||||
ns_binding = get_namespace_binding (current_namespace, name);
|
||||
|
||||
if (ob && ob->scope == current_binding_level->level_chain)
|
||||
/* We have something like:
|
||||
|
||||
int i;
|
||||
for (int i; ;);
|
||||
|
||||
and we are leaving the `for' scope. There's no reason to
|
||||
keep the binding of the inner `i' in this case. */
|
||||
;
|
||||
else if ((ob && (TREE_CODE (ob->value) == TYPE_DECL))
|
||||
|| (ns_binding && TREE_CODE (ns_binding) == TYPE_DECL))
|
||||
/* Here, we have something like:
|
||||
|
||||
typedef int I;
|
||||
|
||||
void f () {
|
||||
for (int I; ;);
|
||||
}
|
||||
|
||||
We must pop the for-scope binding so we know what's a
|
||||
type and what isn't. */
|
||||
;
|
||||
else
|
||||
{
|
||||
/* Mark this VAR_DECL as dead so that we can tell we left it
|
||||
there only for backward compatibility. */
|
||||
DECL_DEAD_FOR_LOCAL (link) = 1;
|
||||
|
||||
/* Keep track of what should have happened when we
|
||||
popped the binding. */
|
||||
if (ob && ob->value)
|
||||
{
|
||||
SET_DECL_SHADOWED_FOR_VAR (link, ob->value);
|
||||
DECL_HAS_SHADOWED_FOR_VAR_P (link) = 1;
|
||||
}
|
||||
|
||||
/* Add it to the list of dead variables in the next
|
||||
outermost binding to that we can remove these when we
|
||||
leave that binding. */
|
||||
vec_safe_push (
|
||||
current_binding_level->level_chain->dead_vars_from_for,
|
||||
link);
|
||||
|
||||
/* Although we don't pop the cxx_binding, we do clear
|
||||
its SCOPE since the scope is going away now. */
|
||||
IDENTIFIER_BINDING (name)->scope
|
||||
= current_binding_level->level_chain;
|
||||
|
||||
/* Don't remove the binding. */
|
||||
name = NULL_TREE;
|
||||
}
|
||||
}
|
||||
/* Remove the binding. */
|
||||
if (TREE_CODE (decl) == LABEL_DECL)
|
||||
pop_local_label (name, decl);
|
||||
|
@ -776,12 +703,6 @@ poplevel (int keep, int reverse, int functionbody)
|
|||
pop_local_binding (name, decl);
|
||||
}
|
||||
|
||||
/* Remove declarations for any `for' variables from inner scopes
|
||||
that we kept around. */
|
||||
FOR_EACH_VEC_SAFE_ELT_REVERSE (current_binding_level->dead_vars_from_for,
|
||||
ix, decl)
|
||||
pop_local_binding (DECL_NAME (decl), decl);
|
||||
|
||||
/* Restore the IDENTIFIER_TYPE_VALUEs. */
|
||||
for (link = current_binding_level->type_shadowed;
|
||||
link; link = TREE_CHAIN (link))
|
||||
|
@ -4170,11 +4091,6 @@ cxx_init_decl_processing (void)
|
|||
pop_namespace ();
|
||||
|
||||
flag_noexcept_type = (cxx_dialect >= cxx17);
|
||||
/* There's no fixed location for <command-line>, the current
|
||||
location is <builtins>, which is somewhat confusing. */
|
||||
if (!flag_new_for_scope)
|
||||
warning_at (UNKNOWN_LOCATION, OPT_Wdeprecated,
|
||||
"%<-fno-for-scope%> is deprecated");
|
||||
|
||||
c_common_nodes_and_builtins ();
|
||||
|
||||
|
|
|
@ -144,9 +144,7 @@ find_local_binding (cp_binding_level *b, tree name)
|
|||
if (cxx_binding *binding = IDENTIFIER_BINDING (name))
|
||||
for (;; b = b->level_chain)
|
||||
{
|
||||
if (binding->scope == b
|
||||
&& !(VAR_P (binding->value)
|
||||
&& DECL_DEAD_FOR_LOCAL (binding->value)))
|
||||
if (binding->scope == b)
|
||||
return binding;
|
||||
|
||||
/* Cleanup contours are transparent to the language. */
|
||||
|
@ -2632,8 +2630,6 @@ check_local_shadow (tree decl)
|
|||
old = binding->value;
|
||||
old_scope = binding->scope;
|
||||
}
|
||||
while (old && VAR_P (old) && DECL_DEAD_FOR_LOCAL (old))
|
||||
old = DECL_SHADOWED_FOR_VAR (old);
|
||||
|
||||
tree shadowed = NULL_TREE;
|
||||
if (old
|
||||
|
@ -3213,84 +3209,6 @@ push_local_binding (tree id, tree decl, bool is_using)
|
|||
add_decl_to_level (b, decl);
|
||||
}
|
||||
|
||||
/* 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.
|
||||
|
||||
FIXME: Scheduled for removal after GCC-8 is done. */
|
||||
|
||||
tree
|
||||
check_for_out_of_scope_variable (tree decl)
|
||||
{
|
||||
tree shadowed;
|
||||
|
||||
/* We only care about out of scope variables. */
|
||||
if (!(VAR_P (decl) && DECL_DEAD_FOR_LOCAL (decl)))
|
||||
return decl;
|
||||
|
||||
shadowed = DECL_HAS_SHADOWED_FOR_VAR_P (decl)
|
||||
? DECL_SHADOWED_FOR_VAR (decl) : NULL_TREE ;
|
||||
while (shadowed != NULL_TREE && VAR_P (shadowed)
|
||||
&& DECL_DEAD_FOR_LOCAL (shadowed))
|
||||
shadowed = DECL_HAS_SHADOWED_FOR_VAR_P (shadowed)
|
||||
? DECL_SHADOWED_FOR_VAR (shadowed) : NULL_TREE;
|
||||
if (!shadowed)
|
||||
shadowed = find_namespace_value (current_namespace, DECL_NAME (decl));
|
||||
if (shadowed)
|
||||
{
|
||||
if (!DECL_ERROR_REPORTED (decl)
|
||||
&& flag_permissive
|
||||
&& warning (0, "name lookup of %qD changed", DECL_NAME (decl)))
|
||||
{
|
||||
inform (DECL_SOURCE_LOCATION (shadowed),
|
||||
"matches this %qD under ISO standard rules", shadowed);
|
||||
inform (DECL_SOURCE_LOCATION (decl),
|
||||
" matches this %qD 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 (TREE_TYPE (decl) == error_mark_node)
|
||||
return decl;
|
||||
|
||||
if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
|
||||
{
|
||||
error ("name lookup of %qD changed for ISO %<for%> scoping",
|
||||
DECL_NAME (decl));
|
||||
inform (DECL_SOURCE_LOCATION (decl),
|
||||
"cannot use obsolete binding %qD because it has a destructor",
|
||||
decl);
|
||||
return error_mark_node;
|
||||
}
|
||||
else
|
||||
{
|
||||
permerror (input_location,
|
||||
"name lookup of %qD changed for ISO %<for%> scoping",
|
||||
DECL_NAME (decl));
|
||||
if (flag_permissive)
|
||||
inform (DECL_SOURCE_LOCATION (decl),
|
||||
"using obsolete binding %qD", decl);
|
||||
static bool hint;
|
||||
if (!hint)
|
||||
inform (input_location, flag_permissive
|
||||
? "this flexibility is deprecated and will be removed"
|
||||
: "if you use %<-fpermissive%> G++ will accept your code");
|
||||
hint = true;
|
||||
}
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
/* true means unconditionally make a BLOCK for the next level pushed. */
|
||||
|
||||
|
|
|
@ -205,11 +205,6 @@ struct GTY(()) cp_binding_level {
|
|||
/* The binding level which this one is contained in (inherits from). */
|
||||
cp_binding_level *level_chain;
|
||||
|
||||
/* List of VAR_DECLS saved from a previous for statement.
|
||||
These would be dead in ISO-conforming code, but might
|
||||
be referenced in ARM-era code. */
|
||||
vec<tree, va_gc> *dead_vars_from_for;
|
||||
|
||||
/* STATEMENT_LIST for statements in this binding contour.
|
||||
Only used at present for SK_CLEANUP temporary bindings. */
|
||||
tree statement_list;
|
||||
|
|
|
@ -5585,27 +5585,10 @@ cp_parser_primary_expression (cp_parser *parser,
|
|||
if (parser->local_variables_forbidden_p
|
||||
&& local_variable_p (decl))
|
||||
{
|
||||
/* It might be that we only found DECL because we are
|
||||
trying to be generous with pre-ISO scoping rules.
|
||||
For example, consider:
|
||||
|
||||
int i;
|
||||
void g() {
|
||||
for (int i = 0; i < 10; ++i) {}
|
||||
extern void f(int j = i);
|
||||
}
|
||||
|
||||
Here, name look up will originally find the out
|
||||
of scope `i'. We need to issue a warning message,
|
||||
but then use the global `i'. */
|
||||
decl = check_for_out_of_scope_variable (decl);
|
||||
if (local_variable_p (decl))
|
||||
{
|
||||
error_at (id_expr_token->location,
|
||||
"local variable %qD may not appear in this context",
|
||||
decl.get_value ());
|
||||
return error_mark_node;
|
||||
}
|
||||
error_at (id_expr_token->location,
|
||||
"local variable %qD may not appear in this context",
|
||||
decl.get_value ());
|
||||
return error_mark_node;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13683,9 +13683,6 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
|
|||
}
|
||||
if (VAR_P (r))
|
||||
{
|
||||
/* Even if the original location is out of scope, the
|
||||
newly substituted one is not. */
|
||||
DECL_DEAD_FOR_LOCAL (r) = 0;
|
||||
DECL_INITIALIZED_P (r) = 0;
|
||||
DECL_TEMPLATE_INSTANTIATED (r) = 0;
|
||||
if (type == error_mark_node)
|
||||
|
|
|
@ -934,9 +934,7 @@ finish_return_stmt (tree expr)
|
|||
tree
|
||||
begin_for_scope (tree *init)
|
||||
{
|
||||
tree scope = NULL_TREE;
|
||||
if (flag_new_for_scope)
|
||||
scope = do_pushlevel (sk_for);
|
||||
tree scope = do_pushlevel (sk_for);
|
||||
|
||||
if (processing_template_decl)
|
||||
*init = push_stmt_list ();
|
||||
|
@ -960,10 +958,10 @@ begin_for_stmt (tree scope, tree init)
|
|||
|
||||
if (scope == NULL_TREE)
|
||||
{
|
||||
gcc_assert (!init || !flag_new_for_scope);
|
||||
if (!init)
|
||||
scope = begin_for_scope (&init);
|
||||
gcc_assert (!init);
|
||||
scope = begin_for_scope (&init);
|
||||
}
|
||||
|
||||
FOR_INIT_STMT (r) = init;
|
||||
FOR_SCOPE (r) = scope;
|
||||
|
||||
|
@ -1057,16 +1055,12 @@ finish_for_stmt (tree for_stmt)
|
|||
FOR_BODY (for_stmt) = do_poplevel (FOR_BODY (for_stmt));
|
||||
|
||||
/* Pop the scope for the body of the loop. */
|
||||
if (flag_new_for_scope)
|
||||
{
|
||||
tree scope;
|
||||
tree *scope_ptr = (TREE_CODE (for_stmt) == RANGE_FOR_STMT
|
||||
? &RANGE_FOR_SCOPE (for_stmt)
|
||||
: &FOR_SCOPE (for_stmt));
|
||||
scope = *scope_ptr;
|
||||
*scope_ptr = NULL;
|
||||
add_stmt (do_poplevel (scope));
|
||||
}
|
||||
tree *scope_ptr = (TREE_CODE (for_stmt) == RANGE_FOR_STMT
|
||||
? &RANGE_FOR_SCOPE (for_stmt)
|
||||
: &FOR_SCOPE (for_stmt));
|
||||
tree scope = *scope_ptr;
|
||||
*scope_ptr = NULL;
|
||||
add_stmt (do_poplevel (scope));
|
||||
}
|
||||
|
||||
/* Begin a range-for-statement. Returns a new RANGE_FOR_STMT.
|
||||
|
@ -1077,18 +1071,15 @@ finish_for_stmt (tree for_stmt)
|
|||
tree
|
||||
begin_range_for_stmt (tree scope, tree init)
|
||||
{
|
||||
tree r;
|
||||
|
||||
begin_maybe_infinite_loop (boolean_false_node);
|
||||
|
||||
r = build_stmt (input_location, RANGE_FOR_STMT,
|
||||
NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE);
|
||||
tree r = build_stmt (input_location, RANGE_FOR_STMT,
|
||||
NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE);
|
||||
|
||||
if (scope == NULL_TREE)
|
||||
{
|
||||
gcc_assert (!init || !flag_new_for_scope);
|
||||
if (!init)
|
||||
scope = begin_for_scope (&init);
|
||||
gcc_assert (!init);
|
||||
scope = begin_for_scope (&init);
|
||||
}
|
||||
|
||||
/* RANGE_FOR_STMTs do not use nor save the init tree, so we
|
||||
|
@ -3560,11 +3551,6 @@ finish_id_expression (tree id_expression,
|
|||
else
|
||||
decl = id_expression;
|
||||
}
|
||||
/* If DECL is a variable that would be out of scope under
|
||||
ANSI/ISO rules, but in scope in the ARM, name lookup
|
||||
will succeed. Issue a diagnostic here. */
|
||||
else
|
||||
decl = check_for_out_of_scope_variable (decl);
|
||||
|
||||
/* Remember that the name was used in the definition of
|
||||
the current class so that we can check later to see if
|
||||
|
|
|
@ -23840,17 +23840,6 @@ superior alternatives. Using the old features might cause a warning in
|
|||
some cases that the feature will be dropped in the future. In other
|
||||
cases, the feature might be gone already.
|
||||
|
||||
While the list below is not exhaustive, it documents some of the options
|
||||
that are now deprecated or have been removed:
|
||||
|
||||
@table @code
|
||||
|
||||
@item -fno-for-scope
|
||||
This option provides compatibility with pre-standard C++.
|
||||
@xref{Backwards Compatibility}.
|
||||
|
||||
@end table
|
||||
|
||||
G++ allows a virtual function returning @samp{void *} to be overridden
|
||||
by one returning a different pointer type. This extension to the
|
||||
covariant return type rules is now deprecated and will be removed from a
|
||||
|
@ -23893,18 +23882,6 @@ liable to disappear in future versions of G++.} They should be considered
|
|||
deprecated. @xref{Deprecated Features}.
|
||||
|
||||
@table @code
|
||||
@item For scope
|
||||
If a variable is declared at for scope, it used to remain in scope
|
||||
until the end of the scope that contained the for statement (rather
|
||||
than just within the for scope). The deprecated
|
||||
@option{-fno-for-scope} option enables this non-standard behavior.
|
||||
Without the option, G++ retains this, but issues a warning, if such a
|
||||
variable is accessed outside the for scope.
|
||||
|
||||
The behavior is deprecated, only available with @option{-std=c++98}
|
||||
@option{-std=gnu++98} languages and you must use the
|
||||
@option{-fpermissive} option to enable it. The behavior will be
|
||||
removed.
|
||||
|
||||
@item Implicit C language
|
||||
Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
|
||||
|
@ -23912,6 +23889,7 @@ scope to set the language. On such systems, all header files are
|
|||
implicitly scoped inside a C language scope. Also, an empty prototype
|
||||
@code{()} is treated as an unspecified number of arguments, rather
|
||||
than no arguments, as C++ demands.
|
||||
|
||||
@end table
|
||||
|
||||
@c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
|
||||
|
|
|
@ -195,7 +195,7 @@ in the following sections.
|
|||
-fconstexpr-depth=@var{n} -fconstexpr-loop-limit=@var{n} @gol
|
||||
-fno-elide-constructors @gol
|
||||
-fno-enforce-eh-specs @gol
|
||||
-ffor-scope -fno-for-scope -fno-gnu-keywords @gol
|
||||
-fno-gnu-keywords @gol
|
||||
-fno-implicit-templates @gol
|
||||
-fno-implicit-inline-templates @gol
|
||||
-fno-implement-inlines -fms-extensions @gol
|
||||
|
@ -2490,21 +2490,6 @@ On targets that support symbol aliases, the default is
|
|||
@option{-fextern-tls-init}. On targets that do not support symbol
|
||||
aliases, the default is @option{-fno-extern-tls-init}.
|
||||
|
||||
@item -ffor-scope
|
||||
@itemx -fno-for-scope
|
||||
@opindex ffor-scope
|
||||
@opindex fno-for-scope
|
||||
If @option{-ffor-scope} is specified, the scope of variables declared in
|
||||
a @i{for-init-statement} is limited to the @code{for} loop itself,
|
||||
as specified by the C++ standard.
|
||||
If @option{-fno-for-scope} is specified, the scope of variables declared in
|
||||
a @i{for-init-statement} extends to the end of the enclosing scope,
|
||||
as was the case in old versions of G++, and other (traditional)
|
||||
implementations of C++.
|
||||
|
||||
This option is deprecated and the associated non-standard
|
||||
functionality will be removed.
|
||||
|
||||
@item -fno-gnu-keywords
|
||||
@opindex fno-gnu-keywords
|
||||
Do not recognize @code{typeof} as a keyword, so that code can use this
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2018-05-07 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
* objcp-lang.c (objcxx_init_ts): Don't call init_shadowed_var_for_decl.
|
||||
|
||||
2018-01-03 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
Update copyright years.
|
||||
|
@ -28,7 +32,7 @@
|
|||
|
||||
* objcp-decl.c: Remove unused header files.
|
||||
* objcp-lang.c: Likewise.
|
||||
|
||||
|
||||
2015-10-29 Andrew MacLeod <amacleod@redhat.com>
|
||||
|
||||
* objcp-decl.c: Reorder #include's and remove duplicates.
|
||||
|
@ -43,7 +47,7 @@
|
|||
|
||||
* objcp-decl.c: Do not include input.h, line-map.h or is-a.h.
|
||||
* objcp-lang.c: Likewise.
|
||||
|
||||
|
||||
2015-06-08 Andrew MacLeod <amacleod@redhat.com>
|
||||
|
||||
* objcp-decl.c : Adjust include files.
|
||||
|
|
|
@ -87,8 +87,6 @@ objcxx_init_ts (void)
|
|||
{
|
||||
objc_common_init_ts ();
|
||||
cp_common_init_ts ();
|
||||
|
||||
init_shadowed_var_for_decl ();
|
||||
}
|
||||
|
||||
#include "gtype-objcp.h"
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2018-05-07 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
* g++.dg/cpp0x/range-for10.C: Delete.
|
||||
* g++.dg/ext/forscope1.C: Delete.
|
||||
* g++.dg/ext/forscope2.C: Delete.
|
||||
* g++.dg/template/for1.C: Delete.
|
||||
|
||||
2018-05-07 Jeff Law <law@redhat.com>
|
||||
|
||||
* gfortran.dg/linefile.f90: New test.
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
// PR c++/47388
|
||||
// { dg-do compile { target c++11 } }
|
||||
// { dg-options "-fno-for-scope -Wno-deprecated" }
|
||||
|
||||
template <int>
|
||||
void
|
||||
foo ()
|
||||
{
|
||||
int a[] = { 1, 2, 3, 4 };
|
||||
for (int i : a)
|
||||
;
|
||||
}
|
||||
|
||||
void
|
||||
bar ()
|
||||
{
|
||||
foo <0> ();
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
// { dg-do compile }
|
||||
// { dg-options "-fno-for-scope -Wno-deprecated" }
|
||||
|
||||
// Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
// Contributed by Nathan Sidwell 4 Sept 2001 <nathan@codesourcery.com>
|
||||
|
||||
// Bug 4206. We were nesting SCOPE_STMTs badly.
|
||||
|
||||
|
||||
struct A
|
||||
{
|
||||
A ();
|
||||
~A ();
|
||||
};
|
||||
|
||||
|
||||
void Go( )
|
||||
{
|
||||
for (int i = 1;;)
|
||||
{
|
||||
switch (1) {
|
||||
default: {}
|
||||
}
|
||||
A d;
|
||||
}
|
||||
i;
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
// { dg-do compile }
|
||||
// { dg-options "-fpermissive -std=c++98" }
|
||||
|
||||
// Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
// Contributed by Nathan Sidwell 4 Sept 2001 <nathan@codesourcery.com>
|
||||
|
||||
// Bug 4206. We were nesting SCOPE_STMTs badly.
|
||||
|
||||
|
||||
struct A
|
||||
{
|
||||
A ();
|
||||
~A ();
|
||||
};
|
||||
|
||||
|
||||
void Go( )
|
||||
{
|
||||
for (int i = 1;;) // { dg-message "using obsolete binding" }
|
||||
{
|
||||
switch (1) {
|
||||
default: {}
|
||||
}
|
||||
A d;
|
||||
}
|
||||
i; // { dg-warning "name lookup" }
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
// PR c++/47388
|
||||
// { dg-do compile }
|
||||
// { dg-options "-fno-for-scope -Wno-deprecated" }
|
||||
|
||||
template <int>
|
||||
void
|
||||
foo ()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 16; i++)
|
||||
;
|
||||
for (int j = 0; j < 16; j++)
|
||||
;
|
||||
if (j != 16)
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
|
||||
void
|
||||
bar ()
|
||||
{
|
||||
foo <0> ();
|
||||
}
|
Loading…
Reference in New Issue