public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Bernd Edlinger <bernd.edlinger@hotmail.de>
Cc: Joseph Myers <joseph@codesourcery.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	Jeff Law <law@redhat.com>
Subject: Re: [PATCH, C++] Warn on redefinition of builtin functions (PR c++/71973)
Date: Wed, 02 Nov 2016 17:51:00 -0000	[thread overview]
Message-ID: <a73088b4-4c47-02d5-75cd-287cdf11445e@redhat.com> (raw)
In-Reply-To: <AM4PR0701MB2162F194792E4F8E3F267AB3E4A00@AM4PR0701MB2162.eurprd07.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 4988 bytes --]

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
>>> <bernd.edlinger@hotmail.de> 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


[-- Attachment #2: rem-ant.diff --]
[-- Type: text/x-patch, Size: 1413 bytes --]

commit d93d421435f8c38b2019526c7645a59e79a92cc5
Author: Jason Merrill <jason@redhat.com>
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.  */

  parent reply	other threads:[~2016-11-02 17:51 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-06 14:12 Bernd Edlinger
2016-10-06 14:15 ` Kyrill Tkachov
2016-10-06 20:37   ` Bernd Edlinger
2016-10-10 21:47     ` Bernd Edlinger
2016-10-16 19:47 ` Bernd Edlinger
2016-10-17 18:06   ` Joseph Myers
2016-10-17 19:18     ` Bernd Edlinger
2016-10-24 13:37       ` [PING] " Bernd Edlinger
2016-11-01 14:56         ` [PING**2] " Bernd Edlinger
2016-11-01 15:02       ` Jason Merrill
2016-11-01 15:25         ` Bernd Edlinger
2016-11-01 15:20       ` Jason Merrill
2016-11-01 15:45         ` Bernd Edlinger
2016-11-01 17:12           ` Jason Merrill
2016-11-01 18:15             ` Bernd Edlinger
2016-11-01 19:49               ` Jason Merrill
2016-11-01 20:01                 ` Bernd Edlinger
2016-11-01 21:31                   ` Jason Merrill
2016-11-02  6:53                     ` Bernd Edlinger
2016-11-02  6:11               ` Bernd Edlinger
2016-11-02  6:36                 ` Bernd Edlinger
2016-11-02 17:51                 ` Jason Merrill [this message]
2016-11-02 21:15                   ` Bernd Edlinger
2016-11-03 19:58                     ` Jason Merrill
2016-11-05 16:45                       ` Bernd Edlinger
2016-11-18 21:19                         ` Jason Merrill
2016-11-18 22:16                           ` Bernd Edlinger
2016-11-19  1:14                             ` Bernd Edlinger
2016-11-19 11:11                           ` [PATCHv2, " Bernd Edlinger
2016-11-21  5:38                             ` Jason Merrill
2016-11-21 18:56                             ` Jakub Jelinek
2016-11-11 14:24                     ` [PING] [PATCH, " Bernd Edlinger
  -- strict thread matches above, loose matches on Subject: below --
2016-08-20  7:20 Bernd Edlinger
2016-08-22 18:07 ` Joseph Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a73088b4-4c47-02d5-75cd-287cdf11445e@redhat.com \
    --to=jason@redhat.com \
    --cc=bernd.edlinger@hotmail.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=law@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).