Hi, here is a somewhat crude hack, that makes the warning go away. It just prevents the warning if the shadowed symbol is a function and its source file happens to be "<built-in>". Once a real declaration is seen (as in math.h) the source file will be the real source file of the declaration and the warning is emitted. There are sure better ways to do something like this... And, well, I did not make a world, just checked the example program. harti Index: c-decl.c =================================================================== RCS file: /home/ncvs/src/contrib/gcc/c-decl.c,v retrieving revision 1.8 diff -u -r1.8 c-decl.c --- c-decl.c 11 Jul 2003 05:11:14 -0000 1.8 +++ c-decl.c 17 Jul 2003 11:33:00 -0000 _at__at_ -1637,7 +1637,9 _at__at_ shadow_warning ("a previous local", name, oldlocal); } else if (IDENTIFIER_GLOBAL_VALUE (name) != 0 - && IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node) + && IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node + && (!FUNCTION_TYPE_CHECK(IDENTIFIER_GLOBAL_VALUE(name)) || + strcmp(DECL_SOURCE_FILE(IDENTIFIER_GLOBAL_VALUE(name)), "<built-in>") != 0)) shadow_warning ("a global declaration", name, IDENTIFIER_GLOBAL_VALUE (name)); } On Wed, 16 Jul 2003, Jun Kuriyama wrote: JK>At Tue, 15 Jul 2003 11:54:06 -0700, JK>David O'Brien wrote: JK>> Much, much better if you can point to the specific GCC source code file JK>> where this is handled. JK> JK>May this help you? JK> JK> JK>waterblue% cat exp.c JK>int JK>main(int argc, char** argv) JK>{ JK> int exp = 5; JK> JK> return 0; JK>} JK>waterblue% cc -Wshadow -c exp.c JK>exp.c: In function `main': JK>exp.c:4: warning: declaration of `exp' shadows a global declaration JK><built-in>:0: warning: shadowed declaration is here JK> JK> JK> -- harti brandt, http://www.fokus.fraunhofer.de/research/cc/cats/employees/hartmut.brandt/private brandt_at_fokus.fraunhofer.de, harti_at_freebsd.orgReceived on Thu Jul 17 2003 - 02:37:09 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:15 UTC