From patchwork Wed Nov 2 17:51:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 80523 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp251963qge; Wed, 2 Nov 2016 10:51:39 -0700 (PDT) X-Received: by 10.98.97.71 with SMTP id v68mr8964786pfb.133.1478109099829; Wed, 02 Nov 2016 10:51:39 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z15si4240896pge.291.2016.11.02.10.51.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Nov 2016 10:51:39 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-440250-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-440250-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-440250-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=Z1+wXCOx7oFdCmMrm bdXHgD9yObui7ElJnmLjH6F+zVZSLYaHbnzdNQRPqkKKAWGJY36JMRjKG3Uqtwbu gK8jLH/LLNgLpMRDUUfg80xMQpcH7dWGsBM85kZY1XBL3UpfcOhXevtS1dPF3rdM 5xjX4nGxo7+u8HNjGAzxWN7N40= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=WIULepRdGS/whzHuiy/hw9R YSBM=; b=WODKaJtR5cbalimYZOgV2LagUvyyijoXp8JvaLV0mQJBcqPvzCnl8kY wEuTV/xV1g3tw9smhlL2qquY0RF9qpf2NMLrHvua6DPQGfh1noLI1KV3IwDboJRL GFtedJg+KIsDKVaTKXzHT2VW6ZENGEogwrVBAq4b1BQq8yCgIxPU= Received: (qmail 48635 invoked by alias); 2 Nov 2016 17:51:24 -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 47715 invoked by uid 89); 2 Nov 2016 17:51:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=berndedlingerhotmailde, bernd.edlinger@hotmail.de X-HELO: mail-qk0-f182.google.com Received: from mail-qk0-f182.google.com (HELO mail-qk0-f182.google.com) (209.85.220.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Nov 2016 17:51:13 +0000 Received: by mail-qk0-f182.google.com with SMTP id x190so25769723qkb.0 for ; Wed, 02 Nov 2016 10:51:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=UKQD36rw7RubV8n/xFalSlwNZm6S9pgu88qwHPt7dtU=; b=Jxo4onTurpEWZVwz8Ht7cDJV8wByp3Lmx5B93+Q7JW7e14sj0ibHfGRD2EbZlT4iOC 9EAEmPefcTsF7oYN+Ch+yi5L6X70eqc0hKQFdiD6zU17nlT950N9+dXygmfz1QJwWvxD j47nhE3DoI6/2eOyN7A5/Wfp6XiewLcCbZ48cuQ/xVUDBvkbiTL4ZZQJZzL8KPvBhOX5 aHvb8I53cVSNC9O70HjtQffI7j1T9eyx6wKEqUR0ABNP50RKPVDhyh22F7GyVq/2zEhX 7MpCLRxiAeL6K26PD8kDHj0lcxQjaLyQoeLkx1/59hlaPatFy/kwdM2bRqQZj0SzHwjb jx0Q== X-Gm-Message-State: ABUngvey6zUdUMG7jamYBzWu3CSbAh8/3jKvr7q25FUg3gKi+WlA3ZyC9tovkmnSyfJmLQwT X-Received: by 10.55.139.134 with SMTP id n128mr3807425qkd.263.1478109071876; Wed, 02 Nov 2016 10:51:11 -0700 (PDT) Received: from [192.168.1.133] (209-6-90-240.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com. [209.6.90.240]) by smtp.gmail.com with ESMTPSA id j39sm1707778qte.34.2016.11.02.10.51.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Nov 2016 10:51:10 -0700 (PDT) Subject: Re: [PATCH, C++] Warn on redefinition of builtin functions (PR c++/71973) To: Bernd Edlinger References: <3615396e-900c-04f7-f404-82a34de19aea@redhat.com> Cc: Joseph Myers , "gcc-patches@gcc.gnu.org" , Jeff Law From: Jason Merrill Message-ID: Date: Wed, 2 Nov 2016 13:51:09 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes On 11/02/2016 02:11 AM, Bernd Edlinger wrote: > On 11/01/16 19:15, Bernd Edlinger wrote: >> On 11/01/16 18:11, Jason Merrill wrote: >>> On Tue, Nov 1, 2016 at 11:45 AM, Bernd Edlinger >>> wrote: >>>> On 11/01/16 16:20, Jason Merrill wrote: >>>>> On 10/17/2016 03:18 PM, Bernd Edlinger wrote: >>>>> I'm not even sure we need a new warning. Can we combine this warning >>>>> with the block that currently follows? >>>> >>>> After 20 years of not having a warning on that, >>>> an implicitly enabled warning would at least break lots of bogus >>>> test cases. >>> >>> Would it, though? Which test cases still break with the current patch? >> >> Less than before, but there are still at least a few of them. >> >> I can make a list and send it tomorrow. > > FAIL: g++.dg/cpp1y/lambda-generic-udt.C -std=gnu++14 (test for excess > errors) > FAIL: g++.dg/cpp1y/lambda-generic-xudt.C -std=gnu++14 (test for excess > errors) > FAIL: g++.dg/init/new15.C -std=c++11 (test for excess errors) > FAIL: g++.dg/init/new15.C -std=c++14 (test for excess errors) > FAIL: g++.dg/init/new15.C -std=c++98 (test for excess errors) > FAIL: g++.dg/ipa/inline-1.C -std=gnu++11 (test for excess errors) > FAIL: g++.dg/ipa/inline-1.C -std=gnu++14 (test for excess errors) > FAIL: g++.dg/ipa/inline-1.C -std=gnu++98 (test for excess errors) > FAIL: g++.dg/ipa/inline-2.C -std=gnu++11 (test for excess errors) > FAIL: g++.dg/ipa/inline-2.C -std=gnu++14 (test for excess errors) > FAIL: g++.dg/ipa/inline-2.C -std=gnu++98 (test for excess errors) > FAIL: g++.dg/tc1/dr20.C -std=c++11 (test for excess errors) > FAIL: g++.dg/tc1/dr20.C -std=c++14 (test for excess errors) > FAIL: g++.dg/tc1/dr20.C -std=c++98 (test for excess errors) > FAIL: g++.dg/tree-ssa/inline-1.C -std=gnu++11 (test for excess errors) > FAIL: g++.dg/tree-ssa/inline-1.C -std=gnu++14 (test for excess errors) > FAIL: g++.dg/tree-ssa/inline-1.C -std=gnu++98 (test for excess errors) > FAIL: g++.dg/tree-ssa/inline-2.C -std=gnu++11 (test for excess errors) > FAIL: g++.dg/tree-ssa/inline-2.C -std=gnu++14 (test for excess errors) > FAIL: g++.dg/tree-ssa/inline-2.C -std=gnu++98 (test for excess errors) > FAIL: g++.dg/lto/20080908-1 cp_lto_20080908-1_0.o assemble, -O0 -flto > -flto-partition=1to1 -fno-use-linker-plugin > FAIL: g++.dg/lto/20080908-1 cp_lto_20080908-1_0.o assemble, -O0 -flto > -flto-partition=none -fuse-linker-plugin > FAIL: g++.dg/lto/20080908-1 cp_lto_20080908-1_0.o assemble, -O0 -flto > -fuse-linker-plugin -fno-fat-lto-objects > FAIL: g++.dg/lto/20080908-1 cp_lto_20080908-1_0.o assemble, -O2 -flto > -flto-partition=1to1 -fno-use-linker-plugin > FAIL: g++.dg/lto/20080908-1 cp_lto_20080908-1_0.o assemble, -O2 -flto > -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects > FAIL: g++.dg/lto/20080908-1 cp_lto_20080908-1_0.o assemble, -O2 -flto > -fuse-linker-plugin > FAIL: g++.dg/lto/pr68811 cp_lto_pr68811_0.o assemble, -O2 > FAIL: g++.old-deja/g++.law/except1.C -std=gnu++11 (test for excess errors) > FAIL: g++.old-deja/g++.law/except1.C -std=gnu++14 (test for excess errors) > FAIL: g++.old-deja/g++.law/except1.C -std=gnu++98 (test for excess errors) > FAIL: g++.old-deja/g++.mike/p700.C -std=gnu++11 (test for excess errors) > FAIL: g++.old-deja/g++.mike/p700.C -std=gnu++14 (test for excess errors) > FAIL: g++.old-deja/g++.mike/p700.C -std=gnu++98 (test for excess errors) > FAIL: g++.old-deja/g++.other/builtins10.C -std=c++11 (test for excess > errors) > FAIL: g++.old-deja/g++.other/builtins10.C -std=c++14 (test for excess > errors) > FAIL: g++.old-deja/g++.other/realloc.C -std=c++11 (test for excess errors) > FAIL: g++.old-deja/g++.other/realloc.C -std=c++14 (test for excess errors) > FAIL: g++.old-deja/g++.other/realloc.C -std=c++98 (test for excess errors) > FAIL: g++.old-deja/g++.other/vbase5.C -std=c++11 (test for excess errors) > FAIL: g++.old-deja/g++.other/vbase5.C -std=c++14 (test for excess errors) > FAIL: g++.old-deja/g++.other/vbase5.C -std=c++98 (test for excess errors) > > > The lto test case does emit the warning when assembling, but > it still produces an executable and even executes it. > > Also g++.dg/cpp1y/lambda-generic-udt.C, g++.dg/tc1/dr20.C > and g++.old-deja/g++.other/vbase5.C are execution tests. > > So I was wrong to assume these were all compile-only tests. > > I think that list should be fixable, if we decide to enable > the warning by default. Yes, either by fixing the prototypes or disabling the warning. >> If we remove the DECL_ANTICIPATED check, I see some failures in >> builtin* tests due to missing extern "C". That seems appropriate at >> file scope, but I'm not sure it's right for namespace std. > > Interesting, what have you done? The attached. But now that you've found that the existing warning deals with people doing silly things like redeclaring __builtin_* I guess let's leave it alone, and add the warning to the DECL_ANTICIPATED block the way you proposed. Jason commit d93d421435f8c38b2019526c7645a59e79a92cc5 Author: Jason Merrill Date: Tue Nov 1 17:16:12 2016 -0400 rem-ant diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ecf4d14..963087d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1485,10 +1485,6 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) } else if (!types_match) { - /* Avoid warnings redeclaring built-ins which have not been - explicitly declared. */ - if (DECL_ANTICIPATED (olddecl)) - { /* Deal with fileptr_type_node. FILE type is not known at the time we create the builtins. */ tree t1, t2; @@ -1521,8 +1517,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) } else if (! same_type_p (TREE_VALUE (t1), TREE_VALUE (t2))) break; - } - else if ((DECL_EXTERN_C_P (newdecl) + + if ((DECL_EXTERN_C_P (newdecl) && DECL_EXTERN_C_P (olddecl)) || compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)), TYPE_ARG_TYPES (TREE_TYPE (olddecl)))) @@ -1540,7 +1536,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) : G_("shadowing library function %q#D"), olddecl); } else - /* Discard the old built-in function. */ + /* Not a duplicate. */ return NULL_TREE; /* Replace the old RTL to avoid problems with inlining. */