OSDN Git Service

PR c/18624
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Apr 2010 20:33:36 +0000 (20:33 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 00:51:18 +0000 (09:51 +0900)
commitc23f72f25fde8d5583a368b903d1e46bab9f2ff8
treecdb656312907baf618645c9b2bc1a905573733f4
parentf6a4ed8257d0f298f6b53dfd9c66fd67518a8328
PR c/18624
* tree.h (DECL_READ_P): Define.
(struct tree_decl_common): Add decl_read_flag.
* c-decl.c (pop_scope): If TREE_USED but !DECL_READ_P, issue
a set but not used warning.
(merge_decls): Merge DECL_READ_P flag.
(finish_decl, build_compound_literal): Set DECL_READ_P flag.
(finish_function): Issue -Wunused-but-set-parameter diagnostics.
* c-common.c (handle_used_attribute, handle_unused_attribute):
Likewise.
* c-tree.h (default_function_array_read_conversion, mark_exp_read):
New prototypes.
* c-typeck.c (default_function_array_read_conversion, mark_exp_read):
New functions.
(default_conversion, c_process_expr_stmt): Call mark_exp_read.
* c-parser.c (c_parser_initializer, c_parser_expr_no_commas,
c_parser_binary_expression, c_parser_cast_expression,
c_parser_expr_list, c_parser_omp_atomic, c_parser_omp_for_loop):
Call default_function_array_read_conversion instead of
default_function_array_conversion where needed.
(c_parser_unary_expression, c_parser_conditional_expression,
c_parser_postfix_expression_after_primary, c_parser_initelt):
Likewise.  Call mark_exp_read where needed.
(c_parser_statement_after_labels, c_parser_asm_operands,
c_parser_typeof_specifier, c_parser_sizeof_expression,
c_parser_alignof_expression, c_parser_initval): Call mark_exp_read
where needed.
* common.opt (Wunused-but-set-variable, Wunused-but-set-parameter):
New.
* toplev.c (warn_unused_but_set_variable): Default to warn_unused.
(warn_unused_but_set_parameter): Default to warn_unused
&& extra_warnings.
* doc/invoke.texi: Document -Wunused-but-set-variable and
-Wunused-but-set-parameter.

* objc-act.c (finish_var_decl, objc_begin_catch_clause,
really_start_method, get_super_receiver, handle_class_ref): Set
DECL_READ_P in addition to TREE_USED.

* gcc.dg/Wunused-var-1.c: New test.
* gcc.dg/Wunused-var-2.c: New test.
* gcc.dg/Wunused-var-3.c: New test.
* gcc.dg/Wunused-var-4.c: New test.
* gcc.dg/Wunused-var-5.c: New test.
* gcc.dg/Wunused-var-6.c: New test.
* gcc.dg/Wunused-parm-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158086 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/c-typeck.c
gcc/doc/invoke.texi
gcc/objc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wunused-var-1.c
gcc/testsuite/gcc.dg/Wunused-var-2.c
gcc/testsuite/gcc.dg/Wunused-var-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wunused-var-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wunused-var-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wunused-var-6.c [new file with mode: 0644]