From b4976c6247868443df05a67a39995e576c2d9a6d Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 7 Apr 2010 20:33:36 +0000 Subject: 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: https://gcc.gnu.org/svn/gcc/trunk@158086 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c-tree.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcc/c-tree.h') diff --git a/gcc/c-tree.h b/gcc/c-tree.h index dab9d39175e..3681ed7dfec 100644 --- a/gcc/c-tree.h +++ b/gcc/c-tree.h @@ -1,6 +1,6 @@ /* Definitions for C parsing and type checking. Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GCC. @@ -511,7 +511,10 @@ extern bool c_mark_addressable (tree); extern void c_incomplete_type_error (const_tree, const_tree); extern tree c_type_promotes_to (tree); extern struct c_expr default_function_array_conversion (location_t, - struct c_expr); + struct c_expr); +extern struct c_expr default_function_array_read_conversion (location_t, + struct c_expr); +extern void mark_exp_read (tree); extern tree composite_type (tree, tree); extern tree build_component_ref (location_t, tree, tree); extern tree build_array_ref (location_t, tree, tree); -- cgit v1.2.3