diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2004-01-23 18:13:55 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2004-01-23 18:13:55 +0000 |
commit | 04b8f97f29948de584315b23a38d8d1cfc85bd17 (patch) | |
tree | cfd782672a48cf6a1c62786f30ac6d027af6b1d6 /gcc | |
parent | 1ab1739cc6a8c6c9f11075339fea83241a7e966f (diff) | |
download | gcc-04b8f97f29948de584315b23a38d8d1cfc85bd17.zip gcc-04b8f97f29948de584315b23a38d8d1cfc85bd17.tar.gz gcc-04b8f97f29948de584315b23a38d8d1cfc85bd17.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 19 | ||||
-rw-r--r-- | gcc/c-decl.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/builtins-30.c | 27 |
4 files changed, 53 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 619cb99..94a3436 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +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> * config.gcc (powerpc*-*): Clear $with_cpu or $with_tune if it was @@ -9,7 +16,7 @@ [!__powerpc64__]: Corrected to handle kernels with changed ucontext. 2004-01-23 Eric Botcazou <ebotcazou@act-europe.fr> - Olivier Hainque <hainque@act-europe.fr> + Olivier Hainque <hainque@act-europe.fr> * fold-const.c (fold_binary_op_with_conditional_arg): Only build a COMPOUND_EXPR if 'arg' is really a SAVE_EXPR. @@ -34,7 +41,7 @@ 2004-01-23 Alexandre Oliva <aoliva@redhat.com> PR optimization/13819 - * config/sh/sh.c (sh_reorg): Compensate for sharing of CLOBBERs + * config/sh/sh.c (sh_reorg): Compensate for sharing of CLOBBERs introduced by 2004-01-20's Jan Hubicka's copy_insn change. (sh_handle_sp_switch_attribute): Remove warning. @@ -129,7 +136,7 @@ 2004-01-22 Daniel Jacobowitz <drow@mvista.com> * config/arm/arm.c: Include "debug.h". - (thumb_pushpop): Take two new arguments. Add some commentary. + (thumb_pushpop): Take two new arguments. Add some commentary. Output frame information when pushing. (thumb_exit, thumb_unexpanded_epilogue): Update calls to thumb_pushpop. @@ -210,7 +217,7 @@ 2004-01-21 Andrew Pinski <apinski@apple.com> PR target/13785 - * config/rs6000/rs6000.md (call_value): Force operand + * config/rs6000/rs6000.md (call_value): Force operand 1 not operand 0 into a register. 2004-01-21 Kazu Hirata <kazu@cs.umass.edu> @@ -227,7 +234,7 @@ 2004-01-21 Caroline Tice <ctice@apple.com> PR target/12308 - * config/i386/i386.md (fix_truncxfdi2): Add clause to clobber + * config/i386/i386.md (fix_truncxfdi2): Add clause to clobber flags register. (fix_truncdfdi2): Likewise. (fix_truncsfdi2): Likewise. @@ -240,7 +247,7 @@ (fix_truncdfhi2): Likewise. (fix_truncsfhi2): Likewise. (*fix_trunchi_1): Likewise. - + 2004-01-21 Kazu Hirata <kazu@cs.umass.edu> * alias.c, basic-block.h, c-common.c, c-common.h, diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 9316c62..3af82f4 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1029,11 +1029,15 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, extern-inline definition supersedes the extern-inline definition. */ 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) warning ("%Jshadowing built-in function '%D'", newdecl, newdecl); /* Discard the old built-in function. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 20b7183..848ca88 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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> * g++.dg/compat/compat.exp: Add LD_LIBRARY_PATH_32/64 for Solaris. diff --git a/gcc/testsuite/gcc.dg/builtins-30.c b/gcc/testsuite/gcc.dg/builtins-30.c new file mode 100644 index 0000000..a2d7433 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtins-30.c @@ -0,0 +1,27 @@ +/* { 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" } */ +} |