aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.c
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2012-10-29 20:17:23 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2012-10-29 20:17:23 +0000
commit077d1abec135863c50dc0d7a11772b23aae22821 (patch)
tree505d7a759421766b1f73cc99ae4e8492d75f4a37 /gcc/c/c-decl.c
parent36290bb4d5ca29006aaa97d5c1778594dec4ae22 (diff)
downloadgcc-077d1abec135863c50dc0d7a11772b23aae22821.zip
gcc-077d1abec135863c50dc0d7a11772b23aae22821.tar.gz
gcc-077d1abec135863c50dc0d7a11772b23aae22821.tar.bz2
re PR c/53066 (Wshadow should not warn for shadowing an extern function)
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. From-SVN: r192963
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r--gcc/c/c-decl.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 80867ca..f031466 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -2561,8 +2561,18 @@ warn_if_shadowing (tree new_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 if a variable shadows a function, unless
+ the variable is a function or a pointer-to-function. */
+ if (TREE_CODE (old_decl) == FUNCTION_DECL
+ && TREE_CODE (new_decl) != FUNCTION_DECL
+ && !FUNCTION_POINTER_TYPE_P (TREE_TYPE (new_decl)))
+ continue;
+
+ 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))
{