diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2015-06-29 16:25:26 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2015-06-29 16:25:26 +0000 |
commit | da2e71c999f964c6b76581d8dd96c8f9bc48624d (patch) | |
tree | 37d706419594766fd97ec27e029b3959e40e8aa6 /gcc/c-family | |
parent | 77f3f9bf9eaec6f7095f711024d76a342655863b (diff) | |
download | gcc-da2e71c999f964c6b76581d8dd96c8f9bc48624d.zip gcc-da2e71c999f964c6b76581d8dd96c8f9bc48624d.tar.gz gcc-da2e71c999f964c6b76581d8dd96c8f9bc48624d.tar.bz2 |
Wunused-parameter warnings are given from cgraph::finalize_function,
which is the middle-end. This is an oddity compared to other
-Wunused-* warnings. Moreover, Fortran has its own definition of
-Wunused-parameter that conflicts with the middle-end definition.
This patch moves the middle-end part of Wunused-parameter to the C/C++
FEs. I'm not sure if other FEs expected this warning to work. If so,
they do not seem to test for it. Ada, for example, explicitly disables
it.
gcc/ChangeLog:
2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR fortran/66605
* cgraphunit.c (cgraph_node::finalize_function): Do not call
do_warn_unused_parameter.
* function.c (do_warn_unused_parameter): Move from here.
* function.h (do_warn_unused_parameter): Do not declare.
gcc/c-family/ChangeLog:
2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR fortran/66605
* c-common.c (do_warn_unused_parameter): Move here.
* c-common.h (do_warn_unused_parameter): Declare.
gcc/ada/ChangeLog:
2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR fortran/66605
* gcc-interface/misc.c (gnat_post_options): No need to disable
warn_unused_parameter anymore.
gcc/cp/ChangeLog:
2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR fortran/66605
* decl.c (finish_function): Call do_warn_unused_parameter.
gcc/testsuite/ChangeLog:
2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR fortran/66605
* gfortran.dg/wunused-parameter.f90: New test.
gcc/c/ChangeLog:
2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR fortran/66605
* c-decl.c (finish_function): Call do_warn_unused_parameter.
From-SVN: r225135
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 17 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 1 |
3 files changed, 24 insertions, 0 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 2d6e3c5..0e03e7e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org> + + PR fortran/66605 + * c-common.c (do_warn_unused_parameter): Move here. + * c-common.h (do_warn_unused_parameter): Declare. + 2015-06-29 Marek Polacek <polacek@redhat.com> PR c/66322 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 8156d6a..ac42e4a 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -12103,6 +12103,23 @@ do_warn_double_promotion (tree result_type, tree type1, tree type2, warning_at (loc, OPT_Wdouble_promotion, gmsgid, source_type, result_type); } +/* Possibly warn about unused parameters. */ + +void +do_warn_unused_parameter (tree fn) +{ + tree decl; + + for (decl = DECL_ARGUMENTS (fn); + decl; decl = DECL_CHAIN (decl)) + if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL + && DECL_NAME (decl) && !DECL_ARTIFICIAL (decl) + && !TREE_NO_WARNING (decl)) + warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_parameter, + "unused parameter %qD", decl); +} + + /* Setup a TYPE_DECL node as a typedef representation. X is a TYPE_DECL for a typedef statement. Create a brand new diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 2b03703..dd98396 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1045,6 +1045,7 @@ extern void warn_for_sign_compare (location_t, tree op0, tree op1, tree result_type, enum tree_code resultcode); +extern void do_warn_unused_parameter (tree); extern void do_warn_double_promotion (tree, tree, tree, const char *, location_t); extern void set_underlying_type (tree); |