Commit e841f997 by Richard Stallman

(duplicate_decls): Never warn if redeclaring a predeclared function.

(duplicate_decls): Never warn if redeclaring
a predeclared function.  Use the new declaration's types
but keep any predeclared volatile flag.

From-SVN: r1227
parent 16ab02ac
...@@ -1190,6 +1190,7 @@ duplicate_decls (newdecl, olddecl) ...@@ -1190,6 +1190,7 @@ duplicate_decls (newdecl, olddecl)
else if (TREE_CODE (olddecl) == FUNCTION_DECL else if (TREE_CODE (olddecl) == FUNCTION_DECL
&& DECL_BUILT_IN (olddecl)) && DECL_BUILT_IN (olddecl))
{ {
/* A function declaration for a built-in function. */
if (!TREE_PUBLIC (newdecl)) if (!TREE_PUBLIC (newdecl))
{ {
/* If you declare a built-in function name as static, the /* If you declare a built-in function name as static, the
...@@ -1204,20 +1205,23 @@ duplicate_decls (newdecl, olddecl) ...@@ -1204,20 +1205,23 @@ duplicate_decls (newdecl, olddecl)
warning_with_decl (newdecl, "conflicting types for built-in function `%s'"); warning_with_decl (newdecl, "conflicting types for built-in function `%s'");
} }
else if (TREE_CODE (olddecl) == FUNCTION_DECL else if (TREE_CODE (olddecl) == FUNCTION_DECL
&& DECL_BUILT_IN_NONANSI (olddecl)) && DECL_SOURCE_LINE (olddecl) == 0)
{ {
/* A function declaration for a predeclared function
that isn't actually built in. */
if (!TREE_PUBLIC (newdecl)) if (!TREE_PUBLIC (newdecl))
{ {
/* If you declare a built-in function name as static, the /* If you declare a it as static, the
built-in definition is overridden, default definition is overridden. */
but optionally warn this was a bad choice of name. */
if (warn_shadow)
warning_with_decl (newdecl, "shadowing library function `%s'");
/* Discard the old built-in function. */
return 0; return 0;
} }
else if (!types_match) else if (!types_match)
warning_with_decl (newdecl, "conflicting types for library function `%s'"); {
/* If the types don't match, use whatever the program declares,
not the predeclared type. Preserve volatility indication. */
TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
return 0;
}
} }
else if (!types_match else if (!types_match
/* Permit char *foo (int, ...); followed by char *foo (); /* Permit char *foo (int, ...); followed by char *foo ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment