This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, C++] Warn on redefinition of builtin functions (PR c++/71973)


On 10/17/2016 03:18 PM, Bernd Edlinger wrote:
Regarding this hunk:

        /* Whether or not the builtin can throw exceptions has no
          bearing on this declarator.  */
-      TREE_NOTHROW (olddecl) = 0;
+      TREE_NOTHROW (olddecl) = TREE_NOTHROW (newdecl);

You may ask, why the old code was working most of the time.
I think, usually, when types_match == true, there happens another
assignment to TREE_NOTHROW, later in that function around line 2183:

       /* Merge the type qualifiers.  */
       if (TREE_READONLY (newdecl))
         TREE_READONLY (olddecl) = 1;
       if (TREE_THIS_VOLATILE (newdecl))
         TREE_THIS_VOLATILE (olddecl) = 1;
       if (TREE_NOTHROW (newdecl))
         TREE_NOTHROW (olddecl) = 1;

This is in a big "if (types_match)", so I think that explains,
why the old code did work normally, and why it fails if the
parameter don't match, but I still have no idea what to say
in the comment, except that the code should exactly do what
the comment above says.

I think a better fix would be to add a copy of TREE_NOTHROW to the else block of the if (types_match), to go with the existing copies of TREE_READONLY and TREE_THIS_VOLATILE. But yes, duplicate_decls is a mess.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]