From: Nathan Sidwell Date: Tue, 23 Jan 2018 12:18:50 +0000 (+0000) Subject: [C++ PATCH] Deprecate ARM-era for scopes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d55d1e4fa9fbab3e47b91391c6a3986ca9f6f1ff;p=gcc.git [C++ PATCH] Deprecate ARM-era for scopes https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01940.html gcc/cp/ Deprecate ARM-era for scope handling * decl.c (poplevel): Flag_new_for_scope is a boolean-like. (cxx_init_decl_processing): Deprecate flag_new_for_scope being cleared. * name-lookup.c (check_for_out_of_scope_variable): Deprecate and cleanup handling. * semantics.c (begin_for_scope): Flag_new_for_scope is boolean-like. (finish_for_stmt, begin_range_for_stmt): Likewise. gcc/ * doc/invoke.texi (ffor-scope): Deprecate. gcc/cp/ * g++.dg/cpp0x/range-for10.C: Adjust. * g++.dg/ext/forscope1.C: Adjust. * g++.dg/ext/forscope2.C: Adjust. * g++.dg/template/for1.C: Adjust. From-SVN: r256981 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6718a38fae7..9cda2944ff7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2018-01-23 Nathan Sidwell + + * doc/invoke.texi (ffor-scope): Deprecate. + 2018-01-23 David Malcolm PR tree-optimization/83510 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 004d234a760..bd15f4c045a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2018-01-23 Nathan Sidwell + + Deprecate ARM-era for scope handling + * decl.c (poplevel): Flag_new_for_scope is a boolean-like. + (cxx_init_decl_processing): Deprecate flag_new_for_scope being + cleared. + * name-lookup.c (check_for_out_of_scope_variable): Deprecate and + cleanup handling. + * semantics.c (begin_for_scope): Flag_new_for_scope is + boolean-like. + (finish_for_stmt, begin_range_for_stmt): Likewise. + 2018-01-22 Jason Merrill PR c++/83720 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 230e7ddb880..f6fab422d17 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -644,7 +644,7 @@ poplevel (int keep, int reverse, int functionbody) 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 == 1; + = 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) @@ -4094,6 +4094,8 @@ cxx_init_decl_processing (void) pop_namespace (); flag_noexcept_type = (cxx_dialect >= cxx17); + if (!flag_new_for_scope) + warning (OPT_Wdeprecated, "%<-fno-for-scope%> is deprecated"); c_common_nodes_and_builtins (); diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 8d342939327..c37e52283e4 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -3231,7 +3231,9 @@ push_local_binding (tree id, tree decl, bool is_using) 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. */ + DECL. + + FIXME: Scheduled for removal after GCC-8 is done. */ tree check_for_out_of_scope_variable (tree decl) @@ -3252,16 +3254,16 @@ check_for_out_of_scope_variable (tree decl) shadowed = find_namespace_value (current_namespace, DECL_NAME (decl)); if (shadowed) { - if (!DECL_ERROR_REPORTED (decl)) + if (!DECL_ERROR_REPORTED (decl) + && flag_permissive + && warning (0, "name lookup of %qD changed", DECL_NAME (decl))) { - warning (0, "name lookup of %qD changed", DECL_NAME (decl)); - warning_at (DECL_SOURCE_LOCATION (shadowed), 0, - " matches this %qD under ISO standard rules", - shadowed); - warning_at (DECL_SOURCE_LOCATION (decl), 0, - " matches this %qD under old rules", decl); - DECL_ERROR_REPORTED (decl) = 1; + 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; } @@ -3279,26 +3281,25 @@ check_for_out_of_scope_variable (tree decl) { error ("name lookup of %qD changed for ISO % scoping", DECL_NAME (decl)); - error (" cannot use obsolete binding at %q+D because " - "it has a destructor", 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 % scoping", + permerror (input_location, + "name lookup of %qD changed for ISO % scoping", DECL_NAME (decl)); if (flag_permissive) - permerror (DECL_SOURCE_LOCATION (decl), - " using obsolete binding at %qD", decl); - else - { - static bool hint; - if (!hint) - { - inform (input_location, "(if you use %<-fpermissive%> G++ will accept your code)"); - hint = true; - } - } + 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; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f9c5285f724..b758051965e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -931,7 +931,7 @@ tree begin_for_scope (tree *init) { tree scope = NULL_TREE; - if (flag_new_for_scope > 0) + if (flag_new_for_scope) scope = do_pushlevel (sk_for); if (processing_template_decl) @@ -956,7 +956,7 @@ begin_for_stmt (tree scope, tree init) if (scope == NULL_TREE) { - gcc_assert (!init || !(flag_new_for_scope > 0)); + gcc_assert (!init || !flag_new_for_scope); if (!init) scope = begin_for_scope (&init); } @@ -1053,7 +1053,7 @@ 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 > 0) + if (flag_new_for_scope) { tree scope; tree *scope_ptr = (TREE_CODE (for_stmt) == RANGE_FOR_STMT @@ -1082,7 +1082,7 @@ begin_range_for_stmt (tree scope, tree init) if (scope == NULL_TREE) { - gcc_assert (!init || !(flag_new_for_scope > 0)); + gcc_assert (!init || !flag_new_for_scope); if (!init) scope = begin_for_scope (&init); } diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 27c597492be..891de733160 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -2467,9 +2467,8 @@ 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++. -If neither flag is given, the default is to follow the standard, -but to allow and give a warning for old-style code that would -otherwise be invalid, or have different behavior. +This option is deprecated and the associated non-standard +functionality will be removed. @item -fno-gnu-keywords @opindex fno-gnu-keywords diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 827bcba4d53..bcbaa4c6003 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-01-23 Nathan Sidwell + + * g++.dg/cpp0x/range-for10.C: Adjust. + * g++.dg/ext/forscope1.C: Adjust. + * g++.dg/ext/forscope2.C: Adjust. + * g++.dg/template/for1.C: Adjust. + 2018-01-23 David Malcolm PR tree-optimization/83510 diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for10.C b/gcc/testsuite/g++.dg/cpp0x/range-for10.C index 1397830908d..7288a3b8b0c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/range-for10.C +++ b/gcc/testsuite/g++.dg/cpp0x/range-for10.C @@ -1,6 +1,6 @@ // PR c++/47388 // { dg-do compile { target c++11 } } -// { dg-options "-fno-for-scope" } +// { dg-options "-fno-for-scope -Wno-deprecated" } template void diff --git a/gcc/testsuite/g++.dg/ext/forscope1.C b/gcc/testsuite/g++.dg/ext/forscope1.C index fa6401a3b94..cf0cb2c5c9b 100644 --- a/gcc/testsuite/g++.dg/ext/forscope1.C +++ b/gcc/testsuite/g++.dg/ext/forscope1.C @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-options -fno-for-scope } +// { dg-options "-fno-for-scope -Wno-deprecated" } // Copyright (C) 2001 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 4 Sept 2001 diff --git a/gcc/testsuite/g++.dg/ext/forscope2.C b/gcc/testsuite/g++.dg/ext/forscope2.C index 460b2400a27..3490d3f285c 100644 --- a/gcc/testsuite/g++.dg/ext/forscope2.C +++ b/gcc/testsuite/g++.dg/ext/forscope2.C @@ -16,7 +16,7 @@ struct A void Go( ) { - for (int i = 1;;) // { dg-warning "using obsolete binding" } + for (int i = 1;;) // { dg-message "using obsolete binding" } { switch (1) { default: {} diff --git a/gcc/testsuite/g++.dg/template/for1.C b/gcc/testsuite/g++.dg/template/for1.C index dc33afcdaec..ebb444531e6 100644 --- a/gcc/testsuite/g++.dg/template/for1.C +++ b/gcc/testsuite/g++.dg/template/for1.C @@ -1,6 +1,6 @@ // PR c++/47388 // { dg-do compile } -// { dg-options "-fno-for-scope" } +// { dg-options "-fno-for-scope -Wno-deprecated" } template void