Commit 04b8f97f by Zack Weinberg

re PR c/18314 (Abnormal behavior in optimization)

	PR 18314
	* c-decl.c (diagnose_mismatched_decls): Also discard a
	built-in if we encounter an old-style definition with the
	same name.
testsuite:
	* gcc.dg/builtins-30.c: New testcase.

From-SVN: r76441
parent 1ab1739c
2004-01-23 Zack Weinberg <zack@codesourcery.com>
PR 18314
* c-decl.c (diagnose_mismatched_decls): Also discard a
built-in if we encounter an old-style definition with the
same name.
2004-01-23 Jakub Jelinek <jakub@redhat.com> 2004-01-23 Jakub Jelinek <jakub@redhat.com>
* config.gcc (powerpc*-*): Clear $with_cpu or $with_tune if it was * config.gcc (powerpc*-*): Clear $with_cpu or $with_tune if it was
......
...@@ -1029,11 +1029,15 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, ...@@ -1029,11 +1029,15 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
extern-inline definition supersedes the extern-inline definition. */ extern-inline definition supersedes the extern-inline definition. */
else if (TREE_CODE (newdecl) == FUNCTION_DECL) else if (TREE_CODE (newdecl) == FUNCTION_DECL)
{ {
if (DECL_BUILT_IN (olddecl) && !TREE_PUBLIC (newdecl)) /* If you declare a built-in function name as static, or
define the built-in with an old-style definition (so we
can't validate the argument list) the built-in definition is
overridden, but optionally warn this was a bad choice of name. */
if (DECL_BUILT_IN (olddecl)
&& (!TREE_PUBLIC (newdecl)
|| (DECL_INITIAL (newdecl)
&& !TYPE_ARG_TYPES (TREE_TYPE (newdecl)))))
{ {
/* If you declare a built-in function name as static, the
built-in definition is overridden,
but optionally warn this was a bad choice of name. */
if (warn_shadow) if (warn_shadow)
warning ("%Jshadowing built-in function '%D'", newdecl, newdecl); warning ("%Jshadowing built-in function '%D'", newdecl, newdecl);
/* Discard the old built-in function. */ /* Discard the old built-in function. */
......
2004-01-23 Zack Weinberg <zack@codesourcery.com>
PR 18314
* gcc.dg/builtins-30.c: New testcase.
2004-01-23 Andreas Tobler <a.tobler@schweiz.ch> 2004-01-23 Andreas Tobler <a.tobler@schweiz.ch>
* g++.dg/compat/compat.exp: Add LD_LIBRARY_PATH_32/64 for Solaris. * g++.dg/compat/compat.exp: Add LD_LIBRARY_PATH_32/64 for Solaris.
......
/* { dg-do compile } */
/* { dg-options "-Wall -Wshadow" } */
extern double strtod (const char *, char **);
#define UNUSED __attribute__ ((unused))
/* A built-in function may be overridden by an old-style definition
specifying too few arguments... */
double nan ()
{
return strtod ("nan", 0); /* { dg-warning "shadowing built-in" } */
}
/* the right number, but the wrong type, arguments... */
float nanf (foo)
int foo UNUSED;
{
return strtod ("nan", 0); /* { dg-warning "shadowing built-in" } */
}
/* or too many arguments. */
long double nanl (foo, bar)
const char *foo UNUSED;
int bar UNUSED;
{
return strtod ("nan", 0); /* { dg-warning "shadowing built-in" } */
}
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