OK.
On Sat, Nov 19, 2016 at 6:11 AM, Bernd Edlinger <bernd.edlin...@hotmail.de> wrote: > Hi, > > On 11/18/16 22:19, Jason Merrill wrote: >> On 11/05/2016 12:44 PM, Bernd Edlinger wrote: >>> + warning_at (DECL_SOURCE_LOCATION (newdecl), 0, >>> + "declaration of %q+#D conflicts with built-in " >>> + "declaration %q#D", newdecl, olddecl); >> >> There needs to be a way to disable this warning, even if it's enabled by >> default. >> >>> - TREE_NOTHROW (olddecl) = 0; >>> + TREE_NOTHROW (olddecl) = TREE_NOTHROW (newdecl); >> >> I still 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. >> > > > I changed the patch as requested. I think meanwhile that this else > block does only handle a built-in function with different signature. > > I have now changed also the C front end to emit the warning with the new > default-enabled -Wbuiltin-declaration-mismatch. > > When I looked at the c-decl.c code, I saw there are effectively two > warnings, one for a function that does not match the builtin signature, > and another for a global variable that has the the name of a built-in. > > like: > test.c > int printf; > > gives warning: > test.c:1:5: warning: built-in function 'printf' declared as non-function > int printf; > > > the same in C++ gives nothing. > > That is because of this in duplicate_decls: > > if (TREE_CODE (newdecl) != FUNCTION_DECL) > { > /* Avoid warnings redeclaring built-ins which have not been > explicitly declared. */ > if (DECL_ANTICIPATED (olddecl)) > return NULL_TREE; > > That is from gcc3.1 in 2002 a rather radical patch I would say. > > I left the warning for declaring a variable with the name of built-in > function for next time, maybe... > > > Bootstrapped and reg-tested on x86_64-pc-linux-gnu. > Is it OK for trunk? > > > Thanks > Bernd.