public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/53066] New: Wshadow should not warn for shadowing an extern function
@ 2012-04-21 15:33 manu at gcc dot gnu.org
2012-04-21 16:42 ` [Bug c/53066] " manu at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: manu at gcc dot gnu.org @ 2012-04-21 15:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53066
Bug #: 53066
Summary: Wshadow should not warn for shadowing an extern
function
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: manu@gcc.gnu.org
As described by Linus here:
http://lkml.indiana.edu/hypermail/linux/kernel/0611.3/1020.html
This makes Wshadow useless on real code.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/53066] Wshadow should not warn for shadowing an extern function
2012-04-21 15:33 [Bug c/53066] New: Wshadow should not warn for shadowing an extern function manu at gcc dot gnu.org
@ 2012-04-21 16:42 ` manu at gcc dot gnu.org
2012-10-29 20:18 ` manu at gcc dot gnu.org
2012-10-29 20:20 ` manu at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: manu at gcc dot gnu.org @ 2012-04-21 16:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53066
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-04-21 16:41:42 UTC ---
Testing this patch:
--- gcc/c-decl.c (revision 186353)
+++ gcc/c-decl.c (working copy)
@@ -2570,12 +2570,19 @@ warn_if_shadowing (tree new_decl)
}
else if (TREE_CODE (old_decl) == PARM_DECL)
warning (OPT_Wshadow, "declaration of %q+D shadows a parameter",
new_decl);
else if (DECL_FILE_SCOPE_P (old_decl))
- warning (OPT_Wshadow, "declaration of %q+D shadows a global "
- "declaration", new_decl);
+ {
+ /* Do not warn for variables shadowing a function
+ declaration. */
+ if (TREE_CODE (old_decl) == FUNCTION_DECL)
+ break;
+ warning_at (DECL_SOURCE_LOCATION (new_decl), OPT_Wshadow,
+ "declaration of %qD shadows a global declaration",
+ new_decl);
+ }
else if (TREE_CODE (old_decl) == FUNCTION_DECL
&& DECL_BUILT_IN (old_decl))
{
warning (OPT_Wshadow, "declaration of %q+D shadows "
"a built-in function", new_decl);
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/53066] Wshadow should not warn for shadowing an extern function
2012-04-21 15:33 [Bug c/53066] New: Wshadow should not warn for shadowing an extern function manu at gcc dot gnu.org
2012-04-21 16:42 ` [Bug c/53066] " manu at gcc dot gnu.org
@ 2012-10-29 20:18 ` manu at gcc dot gnu.org
2012-10-29 20:20 ` manu at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-29 20:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53066
--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-29 20:17:34 UTC ---
Author: manu
Date: Mon Oct 29 20:17:23 2012
New Revision: 192963
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192963
Log:
2012-10-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/53066
c/
* c-decl.c (warn_if_shadowing): Do not warn if a variable
shadows a function, unless the variable is a function or a
pointer-to-function.
gcc/
* tree.h (FUNCTION_POINTER_TYPE_P): New.
testsuite/
* gcc.dg/Wshadow-4.c: New.
* gcc.dg/Wshadow-4.h: New.
Added:
trunk/gcc/testsuite/gcc.dg/Wshadow-4.c
trunk/gcc/testsuite/gcc.dg/Wshadow-4.h
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-decl.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree.h
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/53066] Wshadow should not warn for shadowing an extern function
2012-04-21 15:33 [Bug c/53066] New: Wshadow should not warn for shadowing an extern function manu at gcc dot gnu.org
2012-04-21 16:42 ` [Bug c/53066] " manu at gcc dot gnu.org
2012-10-29 20:18 ` manu at gcc dot gnu.org
@ 2012-10-29 20:20 ` manu at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-29 20:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53066
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.8.0
--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-29 20:20:15 UTC ---
FIXED in GCC 4.8
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-10-29 20:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-21 15:33 [Bug c/53066] New: Wshadow should not warn for shadowing an extern function manu at gcc dot gnu.org
2012-04-21 16:42 ` [Bug c/53066] " manu at gcc dot gnu.org
2012-10-29 20:18 ` manu at gcc dot gnu.org
2012-10-29 20:20 ` manu at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).