From patchwork Thu May 3 19:21:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 908191 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-477202-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="DI6lDbEm"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40cQ6n6TZYz9s4n for ; Fri, 4 May 2018 05:23:44 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Kx2Gl3g/ScEe0r4F3asELyuSv/YEtaPr3chK6JIUhjcY8NVxLN u61Th50bdJgxkDx5mtFb4PEiKmhEieFXfhdN7Z817mPMOT+uGt6uUHBBV8QfUwHU ZFgXg28DxCqwMw6QwcyEZWGaHInNxsnDaJ7tza0D1zv7KNjqB69AFWIME= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=9tFXtELgXjwto6YVAqcTRNlYwuk=; b=DI6lDbEmxbFMdzzrjyjU wcAtCCs9ejwxJESKge0g2vqw/rAm1YyOt0qmDGI6SVfJyBooHHZaxZbmlZFk1YgX NNV/L7qb51I6asSEWXgEHT1M91+Pg/kkEhu42viWjHsXzrA7MwP9lUGkiTBaco/z VXx3kbDPXbEUag3liE1v56U= Received: (qmail 28425 invoked by alias); 3 May 2018 19:23:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 28407 invoked by uid 89); 3 May 2018 19:23:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Injection, cfamily, c-family, name-lookup.c X-HELO: mail-yb0-f173.google.com Received: from mail-yb0-f173.google.com (HELO mail-yb0-f173.google.com) (209.85.213.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 May 2018 19:23:34 +0000 Received: by mail-yb0-f173.google.com with SMTP id x145-v6so6065214ybg.10 for ; Thu, 03 May 2018 12:23:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=bNotO5d5x6wijN5nyhM+6G685CJPwhaCXxiGz2mS0rI=; b=WbcoThvb+yg3dpCq7MN17uWsNGy9jvoUPzL1O75NJXN3768gHxyV3J1wxCzIaewcei BECQtqMTjOGmK6Xwy96TfHuIWGf4q0JlxIksoh6eA87EGi10Xz8jT3XlRSUmmBHY8uDF rht2+zuzoSWA5jknOYyBdAdd+Bqprd76DJ8TK4oG/x288QowetxQ2JiInfPqD/5PV179 jiwteGuzrfYWjn73EYhkWHF8Aq9sbFSJa4cZdCWv0HZT+dO+paTsLztQkfi3o9iQ5Ezk L6qh1N0/oENpXQf9pX61TYCKLOWKUy/lDzLnixCUgl/28DKmqN3zyNEMJP/MGmdMkY8w MmMg== X-Gm-Message-State: ALQs6tAfP3lbBxL1J0XPd+KTujUfXcOu8Vm+OIjDNpfiEiQM71H+TpuG aOexf4fWxyh9QyMeGgNslFU= X-Google-Smtp-Source: AB8JxZoE1fK4SY8urbDWXh5TQfoOjzAF8jJpVpFad9wt4KyuNF4z/J0tdluWC1Crqnwgw10W2Bk8og== X-Received: by 2002:a25:b314:: with SMTP id l20-v6mr451755ybj.472.1525375412493; Thu, 03 May 2018 12:23:32 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::3:3a6d]) by smtp.googlemail.com with ESMTPSA id g132-v6sm5315060ywb.88.2018.05.03.12.23.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 12:23:31 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ Patch] Kill -ffriend-injection Message-ID: <5849adb3-b545-b3ef-ebb9-2c08ebbf9747@acm.org> Date: Thu, 3 May 2018 15:21:58 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 As prophesied in GCC 8.1, it's time to kill friend injection. Committing to trunk. nathan 2018-05-03 Nathan Sidwell * doc/extend.texi (Deprecated Features): Remove -ffriend-injection. (Backwards Compatibility): Likewise. * doc/invoke.texi (C++ Language Options): Likewise. (C++ Dialect Options): Likewise. c-family/ * c.opt (ffriend-injection): Remove functionality, issue warning. cp/ * decl.c (cxx_init_decl_processing): Remove flag_friend_injection. * name-lookup.c (do_pushdecl): Likewise. testsuite/ Remove -ffriend-injection. * g++.old-deja/g++.jason/scoping15.C: Delete. * g++.old-deja/g++.mike/net43.C: Delete. Index: c-family/c.opt =================================================================== --- c-family/c.opt (revision 259900) +++ c-family/c.opt (working copy) @@ -1494,8 +1494,7 @@ C++ ObjC++ Var(flag_new_inheriting_ctors Implement C++17 inheriting constructor semantics. ffriend-injection -C++ ObjC++ Var(flag_friend_injection) -Inject friend functions into enclosing namespace. +C++ ObjC++ Ignore Warn(switch %qs is no longer supported) fkeep-inline-dllexport C C++ ObjC ObjC++ Var(flag_keep_inline_dllexport) Init(1) Report Condition(TARGET_DLLIMPORT_DECL_ATTRIBUTES) Index: cp/decl.c =================================================================== --- cp/decl.c (revision 259900) +++ cp/decl.c (working copy) @@ -4175,9 +4175,6 @@ cxx_init_decl_processing (void) if (!flag_new_for_scope) warning_at (UNKNOWN_LOCATION, OPT_Wdeprecated, "%<-fno-for-scope%> is deprecated"); - if (flag_friend_injection) - warning_at (UNKNOWN_LOCATION, OPT_Wdeprecated, - "%<-ffriend-injection%> is deprecated"); c_common_nodes_and_builtins (); Index: cp/name-lookup.c =================================================================== --- cp/name-lookup.c (revision 259900) +++ cp/name-lookup.c (working copy) @@ -3055,7 +3055,6 @@ do_pushdecl (tree decl, bool is_friend) old = OVL_CHAIN (old); check_template_shadow (decl); - bool visible_injection = false; if (DECL_DECLARES_FUNCTION_P (decl)) { @@ -3073,11 +3072,8 @@ do_pushdecl (tree decl, bool is_friend) /* Don't attempt to push it. */ return error_mark_node; } - if (!flag_friend_injection) - /* Hide it from ordinary lookup. */ - DECL_ANTICIPATED (decl) = DECL_HIDDEN_FRIEND_P (decl) = true; - else - visible_injection = true; + /* Hide it from ordinary lookup. */ + DECL_ANTICIPATED (decl) = DECL_HIDDEN_FRIEND_P (decl) = true; } } @@ -3129,9 +3125,6 @@ do_pushdecl (tree decl, bool is_friend) } else if (VAR_P (decl)) maybe_register_incomplete_var (decl); - else if (visible_injection) - warning (0, "injected friend %qD is visible" - " due to %<-ffriend-injection%>", decl); if ((VAR_P (decl) || TREE_CODE (decl) == FUNCTION_DECL) && DECL_EXTERN_C_P (decl)) Index: doc/extend.texi =================================================================== --- doc/extend.texi (revision 259900) +++ doc/extend.texi (working copy) @@ -23846,8 +23846,7 @@ that are now deprecated or have been rem @table @code @item -fno-for-scope -@itemx -ffriend-injection -These two options provide compatibility with pre-standard C++. +This option provides compatibility with pre-standard C++. @xref{Backwards Compatibility}. @end table @@ -23907,11 +23906,6 @@ The behavior is deprecated, only availab @option{-fpermissive} option to enable it. The behavior will be removed. -@item Friend Injection -The @option{-ffriend-injection} option makes injected friends visible -to regular name lookup, unlike standard C++. This option is -deprecated and will be removed. - @item Implicit C language Old C system header files did not contain an @code{extern "C" @{@dots{}@}} scope to set the language. On such systems, all header files are Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 259900) +++ doc/invoke.texi (working copy) @@ -193,7 +193,6 @@ in the following sections. @gccoptlist{-fabi-version=@var{n} -fno-access-control @gol -faligned-new=@var{n} -fargs-in-order=@var{n} -fcheck-new @gol -fconstexpr-depth=@var{n} -fconstexpr-loop-limit=@var{n} @gol --ffriend-injection @gol -fno-elide-constructors @gol -fno-enforce-eh-specs @gol -ffor-scope -fno-for-scope -fno-gnu-keywords @gol @@ -2448,18 +2447,6 @@ originally proposed semantics for the C+ of the final standard, so it is disabled by default. This option is deprecated, and may be removed in a future version of G++. -@item -ffriend-injection -@opindex ffriend-injection -Inject friend functions into the enclosing namespace, so that they are -visible outside the scope of the class in which they are declared. -Friend functions were documented to work this way in the old Annotated -C++ Reference Manual. -However, in ISO C++ a friend function that is not declared -in an enclosing scope can only be found using argument dependent -lookup. GCC defaults to the standard behavior. - -This option is deprecated and will be removed. - @item -fno-elide-constructors @opindex fno-elide-constructors The C++ standard allows an implementation to omit creating a temporary Index: testsuite/g++.old-deja/g++.jason/scoping15.C =================================================================== --- testsuite/g++.old-deja/g++.jason/scoping15.C (revision 259900) +++ testsuite/g++.old-deja/g++.jason/scoping15.C (working copy) @@ -1,25 +0,0 @@ -// { dg-do assemble } -// { dg-options "-ffriend-injection" } -// Bug: g++ ignores the :: qualification and dies trying to treat an integer -// variable as a list of functions. - -class DComplex; -double imag (const DComplex&); - -class DComplex { -public: - friend double imag(const DComplex& a); // Not injected, no warning -}; - -class FComplex { -public: - friend float imag(const FComplex& a); // { dg-warning "is visible" } -}; - -void -scnrm2(FComplex cx[]) -{ - int imag; - ::imag( cx[0] ); -} -// { dg-warning "ffriend-injection.* is deprecated" "cc1plus:" { target *-*-* } 0 } Index: testsuite/g++.old-deja/g++.mike/net43.C =================================================================== --- testsuite/g++.old-deja/g++.mike/net43.C (revision 259900) +++ testsuite/g++.old-deja/g++.mike/net43.C (working copy) @@ -1,12 +0,0 @@ -// { dg-do assemble } -// { dg-options "-ffriend-injection -Wno-deprecated" } - -class foo { - public: - friend int operator ^(const foo&, const foo&); // { dg-message "is visible" } -}; - -int main () -{ - int (*funptr) (const foo &, const foo &) = operator ^; -}