aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-06-05 05:30:39 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-06-05 05:30:39 +0000
commit6447c55dea95705018ff2bb3de7a81c160a71d4e (patch)
treec4f8e2e13a568c7cf9471b9cf3520957becc359c /gcc/c
parent1f5dc1b6f06b4dde9538d81e341feae7d9c9c441 (diff)
downloadgcc-6447c55dea95705018ff2bb3de7a81c160a71d4e.zip
gcc-6447c55dea95705018ff2bb3de7a81c160a71d4e.tar.gz
gcc-6447c55dea95705018ff2bb3de7a81c160a71d4e.tar.bz2
re PR c/48062 (`shadowed declaration is here' should be a note)
PR c/48062 * c-decl.c (warn_if_shadowing): Call inform instead of warning_at. Print note only if the warning was printed. * gcc.dg/Wshadow-1.c: Use dg-message for "shadowed declaration". * gcc.dg/Wshadow-3.c: Likewise. * gcc.dg/pr48062.c: New test. From-SVN: r211254
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-decl.c22
2 files changed, 19 insertions, 9 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index c51bfb4..7bd3ce3 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-05 Marek Polacek <polacek@redhat.com>
+
+ PR c/48062
+ * c-decl.c (warn_if_shadowing): Call inform instead of warning_at.
+ Print note only if the warning was printed.
+
2014-06-04 Igor Zamyatin <igor.zamyatin@intel.com>
PR c/58942
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index dc8dbc2..8fb3296 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -2601,6 +2601,7 @@ warn_if_shadowing (tree new_decl)
DECL_SOURCE_LOCATION (b->decl))))
{
tree old_decl = b->decl;
+ bool warned = false;
if (old_decl == error_mark_node)
{
@@ -2609,8 +2610,9 @@ warn_if_shadowing (tree new_decl)
break;
}
else if (TREE_CODE (old_decl) == PARM_DECL)
- warning (OPT_Wshadow, "declaration of %q+D shadows a parameter",
- new_decl);
+ warned = warning (OPT_Wshadow,
+ "declaration of %q+D shadows a parameter",
+ new_decl);
else if (DECL_FILE_SCOPE_P (old_decl))
{
/* Do not warn if a variable shadows a function, unless
@@ -2620,9 +2622,10 @@ warn_if_shadowing (tree new_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);
+ warned = 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))
@@ -2632,11 +2635,12 @@ warn_if_shadowing (tree new_decl)
break;
}
else
- warning (OPT_Wshadow, "declaration of %q+D shadows a previous local",
- new_decl);
+ warned = warning (OPT_Wshadow, "declaration of %q+D shadows a "
+ "previous local", new_decl);
- warning_at (DECL_SOURCE_LOCATION (old_decl), OPT_Wshadow,
- "shadowed declaration is here");
+ if (warned)
+ inform (DECL_SOURCE_LOCATION (old_decl),
+ "shadowed declaration is here");
break;
}