summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2016-10-19 01:32:26 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2016-10-19 01:32:26 +0000
commit9902657fd2ce3e407336be2f53662687b5d55a71 (patch)
treecef3832115ee575797b1953ec41f11dbfc16f7ba /gnu
parent8b04b2749a34bf93001e1edea905d14fd732451a (diff)
Don't warn about shadowing a global function unless the local
variable or parameter is a pointer to a function. ok kettenis@
Diffstat (limited to 'gnu')
-rw-r--r--gnu/gcc/gcc/c-decl.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gnu/gcc/gcc/c-decl.c b/gnu/gcc/gcc/c-decl.c
index f09ffd96a04..01975d5f8e9 100644
--- a/gnu/gcc/gcc/c-decl.c
+++ b/gnu/gcc/gcc/c-decl.c
@@ -1946,8 +1946,20 @@ 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);
+ {
+ /* Don't warn about shadowing a global function unless the local
+ variable or parameter is a pointer to a function */
+ if (TREE_CODE (old_decl) == FUNCTION_DECL
+ && TREE_CODE (new_decl) != FUNCTION_DECL
+ && ((TREE_CODE (new_decl) != VAR_DECL
+ && TREE_CODE (new_decl) != PARM_DECL)
+ || !POINTER_TYPE_P (TREE_TYPE (new_decl))
+ || TREE_CODE (TREE_TYPE (TREE_TYPE (new_decl)))
+ != FUNCTION_TYPE))
+ continue;
+ warning (OPT_Wshadow, "declaration of %q+D shadows a global "
+ "declaration", new_decl);
+ }
else if (TREE_CODE (old_decl) == FUNCTION_DECL
&& DECL_BUILT_IN (old_decl))
{