From patchwork Wed Nov 2 21:15:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 690601 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3t8LVr6nHlz9tlB for ; Thu, 3 Nov 2016 08:16:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=FoLrBvIF; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:references:in-reply-to :content-type:mime-version; q=dns; s=default; b=tnttni3QMW3iKmRb UUfu4aPZNbGDi2hxGvkfv+Xx0Vs2qUoJYWP/D3h0p2KnnyApk2HmT0cmLhazfOPp xiaK9XyDO9QZkwlQIXMxKAgAH9UJKbH0S2iM6p7Pb6il9p1ICA2bTxc9vgXwY08N pFpIZEJEjdjZIlQlhtqx1jFYDyw= 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:from :to:cc:subject:date:message-id:references:in-reply-to :content-type:mime-version; s=default; bh=U0DASTBu+6ZEa6ndgL+8C6 tL//E=; b=FoLrBvIF8ZhQP/l7QqnMIVnQYKmuF4AUlxQ7ahtzM5Isgv5tMJ4fMn BQfS/ig9SWdNoUe4SjDufl6WLCuAvOsVouHX2/K1enPVdhEeJZz7BijUGpsijPPM OHaJVG8W8uOht3Wmm+G7AR8dJbB1C08ej0kiSANNMEmh8g8fLmhmk= Received: (qmail 121631 invoked by alias); 2 Nov 2016 21:15:52 -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 121602 invoked by uid 89); 2 Nov 2016 21:15:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 spammy=bajo, giovanni, __file__, __FILE__ X-HELO: BAY004-OMC1S17.hotmail.com Received: from bay004-omc1s17.hotmail.com (HELO BAY004-OMC1S17.hotmail.com) (65.54.190.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Nov 2016 21:15:41 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com ([65.54.190.59]) by BAY004-OMC1S17.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Wed, 2 Nov 2016 14:15:39 -0700 Received: from AM5EUR03FT012.eop-EUR03.prod.protection.outlook.com (10.152.16.58) by AM5EUR03HT103.eop-EUR03.prod.protection.outlook.com (10.152.17.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.6; Wed, 2 Nov 2016 21:15:38 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com (10.152.16.55) by AM5EUR03FT012.mail.protection.outlook.com (10.152.16.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.6 via Frontend Transport; Wed, 2 Nov 2016 21:15:38 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com ([10.167.132.147]) by AM4PR0701MB2162.eurprd07.prod.outlook.com ([10.167.132.147]) with mapi id 15.01.0679.020; Wed, 2 Nov 2016 21:15:38 +0000 From: Bernd Edlinger To: Jason Merrill CC: Joseph Myers , "gcc-patches@gcc.gnu.org" , Jeff Law Subject: Re: [PATCH, C++] Warn on redefinition of builtin functions (PR c++/71973) Date: Wed, 2 Nov 2016 21:15:38 +0000 Message-ID: References: <3615396e-900c-04f7-f404-82a34de19aea@redhat.com> In-Reply-To: authentication-results: redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=hotmail.de; x-ms-exchange-messagesentrepresentingtype: 1 x-eopattributedmessage: 0 x-microsoft-exchange-diagnostics: 1; AM5EUR03HT103; 7:p/o277ZqnS7+JyU8P/tNdSemt+fybIezpuphibTP8Ta2vIeNsRfZV6AeYBHS2f7pyWK5CP+E/wJ+c5cKmawodz/kZloHfU/riibPGri7m5xRTyOX6WhpqffN5CyczWwnV8nmuDEi7UJY9WAk2BqDkb7xfcLtlHrrWQD92GkdLanHqCFVeMZXuHR0HW4nrAHOyZ1cdfNYVSeVOoN9IwKkmBTWaLwja3a8l5gv0JIoLGK4QoeqdTfl2DB95jytlHDlVWlmlaJWDTCWHCg5R4cfX+cuCYWKxvD3b26ha60qA6c/JUK6ZRGZ4eLz53b7NUfuTli81+3xgiC3Lp/nfBJQv1I+2suykzFgEL48qM3OO7U= x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(10019020)(98900003); DIR:OUT; SFP:1102; SCL:1; SRVR:AM5EUR03HT103; H:AM4PR0701MB2162.eurprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-office365-filtering-correlation-id: 223067f3-be1a-4837-ff0a-08d4036563f3 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(1601124038)(1603103101)(1601125047); SRVR:AM5EUR03HT103; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(432015012)(102415321)(82015046); SRVR:AM5EUR03HT103; BCL:0; PCL:0; RULEID:; SRVR:AM5EUR03HT103; x-forefront-prvs: 0114FF88F6 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Nov 2016 21:15:38.2168 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5EUR03HT103 On 11/02/16 18:51, Jason Merrill wrote: > 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. > Yes, I am inclined to enable the warning by default now. Most of the test cases are fixable in a fairly obvious way, see attachment. But I am unsure about g++.old-deja/g++.other/builtins10.C: // { dg-do assemble } // Test that built-in functions don't warn when prototyped without arguments. // Origin: PR c++/9367 // Copyright (C) 2003 Free Software Foundation. extern "C" int snprintf(); PR c++/9367 was a *bogus* warning. Either delete the test case, or change the expectation to the new warning? But the libitm warnings are a real bug, the prototypes of the _ITM_ builtin functions and in the libitm.h simply do not match, that was just not visible before because the test suite does apparently not use -Wall. Bernd. Index: gcc/testsuite/g++.dg/cpp1y/lambda-generic-udt.C =================================================================== --- gcc/testsuite/g++.dg/cpp1y/lambda-generic-udt.C (revision 241752) +++ gcc/testsuite/g++.dg/cpp1y/lambda-generic-udt.C (working copy) @@ -14,7 +14,7 @@ bool shadow = false; }; -extern "C" void printf(...); +extern "C" int printf(const char*, ...); #define assert(e) if (e); else \ printf ("%s:%d: !(%s)\n", __FILE__, __LINE__, #e), __builtin_abort (); Index: gcc/testsuite/g++.dg/init/new15.C =================================================================== --- gcc/testsuite/g++.dg/init/new15.C (revision 241752) +++ gcc/testsuite/g++.dg/init/new15.C (working copy) @@ -1,6 +1,6 @@ // PR c++/9782 -extern "C" void printf(const char*, ...); +extern "C" int printf(const char*, ...); template struct A { Index: gcc/testsuite/g++.dg/ipa/inline-1.C =================================================================== --- gcc/testsuite/g++.dg/ipa/inline-1.C (revision 241752) +++ gcc/testsuite/g++.dg/ipa/inline-1.C (working copy) @@ -3,7 +3,7 @@ /* { dg-add-options bind_pic_locally } */ namespace std { - extern "C" void puts(const char *s); + extern "C" int puts(const char *s); } template void Index: gcc/testsuite/g++.dg/ipa/inline-2.C =================================================================== --- gcc/testsuite/g++.dg/ipa/inline-2.C (revision 241752) +++ gcc/testsuite/g++.dg/ipa/inline-2.C (working copy) @@ -3,7 +3,7 @@ /* { dg-add-options bind_pic_locally } */ namespace std { - extern "C" void puts(const char *s); + extern "C" int puts(const char *s); } template void Index: gcc/testsuite/g++.dg/lto/20080908-1_0.C =================================================================== --- gcc/testsuite/g++.dg/lto/20080908-1_0.C (revision 241752) +++ gcc/testsuite/g++.dg/lto/20080908-1_0.C (working copy) @@ -1,5 +1,5 @@ /* { dg-lto-do run } */ -extern "C" { extern void *memcpy (void *, const void *, unsigned); } +extern "C" { extern void *memcpy (void *, const void *, __SIZE_TYPE__); } inline int bci (const float &source) Index: gcc/testsuite/g++.dg/lto/pr68811_0.C =================================================================== --- gcc/testsuite/g++.dg/lto/pr68811_0.C (revision 241752) +++ gcc/testsuite/g++.dg/lto/pr68811_0.C (working copy) @@ -1,5 +1,5 @@ // { dg-lto-do link } -/* { dg-lto-options "-O2 -w" } */ +/* { dg-lto-options "-O2\\ -w" } */ // { dg-extra-ld-options "-r -nostdlib" } extern "C" char *strcpy(char *, const char *); char InitXPCOMGlue_lastSlash; Index: gcc/testsuite/g++.dg/tc1/dr20.C =================================================================== --- gcc/testsuite/g++.dg/tc1/dr20.C (revision 241752) +++ gcc/testsuite/g++.dg/tc1/dr20.C (working copy) @@ -2,7 +2,7 @@ // Origin: Giovanni Bajo // DR20: Some clarifications needed for 12.8 para 15 -extern "C" void printf(const char*, ...); +extern "C" int printf(const char*, ...); extern "C" void abort(void); int count = 0; Index: gcc/testsuite/g++.dg/tree-ssa/inline-1.C =================================================================== --- gcc/testsuite/g++.dg/tree-ssa/inline-1.C (revision 241752) +++ gcc/testsuite/g++.dg/tree-ssa/inline-1.C (working copy) @@ -3,7 +3,7 @@ /* { dg-add-options bind_pic_locally } */ namespace std { - extern "C" void puts(const char *s); + extern "C" int puts(const char *s); } template void Index: gcc/testsuite/g++.dg/tree-ssa/inline-2.C =================================================================== --- gcc/testsuite/g++.dg/tree-ssa/inline-2.C (revision 241752) +++ gcc/testsuite/g++.dg/tree-ssa/inline-2.C (working copy) @@ -3,7 +3,7 @@ /* { dg-add-options bind_pic_locally } */ namespace std { - extern "C" void puts(const char *s); + extern "C" int puts(const char *s); } template void Index: gcc/testsuite/g++.old-deja/g++.law/except1.C =================================================================== --- gcc/testsuite/g++.old-deja/g++.law/except1.C (revision 241752) +++ gcc/testsuite/g++.old-deja/g++.law/except1.C (working copy) @@ -7,7 +7,7 @@ // Subject: Bugs // Date: Wed, 22 Jul 92 08:29:30 EDT -extern "C" void puts(const char *); +extern "C" int puts(const char *); class foo { public: Index: gcc/testsuite/g++.old-deja/g++.mike/p700.C =================================================================== --- gcc/testsuite/g++.old-deja/g++.mike/p700.C (revision 241752) +++ gcc/testsuite/g++.old-deja/g++.mike/p700.C (working copy) @@ -1,5 +1,5 @@ // { dg-do assemble } -// { dg-options "-Wno-deprecated -Wno-register" } +// { dg-options "-w" } // { dg-error "limited range of data type" "16-bit target" { target xstormy16-*-* } 0 } // prms-id: 700 Index: gcc/testsuite/g++.old-deja/g++.other/realloc.C =================================================================== --- gcc/testsuite/g++.old-deja/g++.other/realloc.C (revision 241752) +++ gcc/testsuite/g++.old-deja/g++.other/realloc.C (working copy) @@ -1,4 +1,5 @@ // { dg-do assemble } +// { dg-options "-w" } extern "C" void realloc(); Index: gcc/testsuite/g++.old-deja/g++.other/vbase5.C =================================================================== --- gcc/testsuite/g++.old-deja/g++.other/vbase5.C (revision 241752) +++ gcc/testsuite/g++.old-deja/g++.other/vbase5.C (working copy) @@ -6,7 +6,7 @@ // vbases. Normally that's just a pessimization, unfortunately during // constructoring it leads to uninitialized reads. -extern "C" int printf (...); +extern "C" int printf (const char*,...); int fail = 0; Index: gcc/testsuite/obj-c++.dg/lto/trivial-1_0.mm =================================================================== --- gcc/testsuite/obj-c++.dg/lto/trivial-1_0.mm (revision 241752) +++ gcc/testsuite/obj-c++.dg/lto/trivial-1_0.mm (working copy) @@ -1,7 +1,7 @@ /* { dg-lto-do run } */ /* { dg-skip-if "Needs OBJC2 ABI" { "*-*-darwin*" && lp64 } { "*" } { "" } } */ extern "C" { -extern int printf (char *,...) ; +extern int printf (const char *,...) ; extern void abort (void) ; }