* [RFC PATCH] Add set but not used warning support for the C FE (PR c/18624)
@ 2009-11-25 9:12 Jakub Jelinek
2009-11-25 16:04 ` Joseph S. Myers
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2009-11-25 9:12 UTC (permalink / raw)
To: Joseph S. Myers, Richard Guenther; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 3318 bytes --]
Hi!
The attached patch is my initial attempt at adding the set but not used
warning (for C for now). Warning during gimplification is probably too
late, because eventhough the C FE now fully folds much less than it used to,
there are inevitably references which don't make it through to the
gimplifier. TREE_USED is usually set in build_external_ref in the C FE,
which is on the other side too early, we don't know at that point whether
the reference is "read" or only "set". So this patch marks variables as
"read" immediately after parsing when it is already known what kind of var
reference it is.
I've bootstrapped this on x86_64-linux with --disable-werror, no make check
yet, and attached is a list of these warnings during bootstrap (many of them
would be errors with -Werror).
I'm open for better names of the new functions/macros, if you have nice
suggestions, I'd appreciate it.
I wonder whether we want to control this warning with a separate -Wunused-*
switch (and whether to include it into -Wunused or not).
I haven't looked at all the warnings in detail, just on a lot of them, and
they looked correct. In some cases they warn about real bugs (like the ones
David/Paolo fixed last night, or e.g. in cfgrtl.c:
if (flag_reorder_blocks_and_partition
&& targetm.have_named_sections
&& e->src != ENTRY_BLOCK_PTR
&& BB_PARTITION (e->src) == BB_COLD_PARTITION
&& !(e->flags & EDGE_CROSSING))
{
rtx bb_note, cur_insn;
bb_note = NULL_RTX;
for (cur_insn = BB_HEAD (bb); cur_insn != NEXT_INSN (BB_END (bb));
cur_insn = NEXT_INSN (cur_insn))
if (NOTE_INSN_BASIC_BLOCK_P (cur_insn))
{
bb_note = cur_insn;
break;
}
if (JUMP_P (BB_END (bb))
&& !any_condjump_p (BB_END (bb))
&& (single_succ_edge (bb)->flags & EDGE_CROSSING))
add_reg_note (BB_END (bb), REG_CROSSING_JUMP, NULL_RTX);
}
where bb_note is computed using dedicated loop but never used), in some
cases they warn about cases where the set but not used warning is caused
by use of preprocessor macros (e.g. soft-fp, libbid), or e.g. in generated
code (insn-emit.c). In the last case, e.g. getting rid of _regs_allocated
warning would be easy, output_peephole2_scratches could print
HARD_REG_SET _regs_allocated;\nCLEAR_HARD_REG_SET (_regs_allocated);\n
only on the first MATCH_SCRATCH, not unconditionally even when there are no
MATCH_SCRATCHes, but getting rid of the other insn-emit.c warnings might
instead result in some workarounds like (void) operands0; etc. added to the
output.
If anyone has suggestions what else should be tested in the testsuite of
this warning, I'd appreciate it too. I guess I should e.g. test vars used
from nested functions, etc.
While the code computes the DECL_READ_P flag for both VAR_DECLs and
PARM_DECLs (I'm not using a decl_lang_N bit because c-common.c needs to set
it too), currently it warns just about function scope vars; to warn also
about PARM_DECLs the warning would need to be done in function.c, which
would require all other FEs to set it (perhaps just to TREE_USED).
Comments?
Jakub
[-- Attachment #2: Y470c --]
[-- Type: text/plain, Size: 21288 bytes --]
2009-11-25 Jakub Jelinek <jakub@redhat.com>
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.
* 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_conditional_expression, 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_postfix_expression_after_primary): Likewise. Call
mark_exp_read where needed.
(c_parser_statement_after_labels, c_parser_asm_operands): Call
mark_exp_read where needed.
* 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/tree.h.jj 2009-11-11 12:09:14.000000000 +0100
+++ gcc/tree.h 2009-11-24 15:17:41.000000000 +0100
@@ -1320,6 +1320,9 @@ extern void omp_clause_range_check_faile
(TREE_CHECK3 (NODE, VAR_DECL, PARM_DECL, \
RESULT_DECL)->decl_common.decl_restricted_flag)
+#define DECL_READ_P(NODE) \
+ (TREE_CHECK2 (NODE, VAR_DECL, PARM_DECL)->decl_common.decl_read_flag)
+
/* In a CALL_EXPR, means that the call is the jump from a thunk to the
thunked-to function. */
#define CALL_FROM_THUNK_P(NODE) (CALL_EXPR_CHECK (NODE)->base.protected_flag)
@@ -2692,8 +2695,12 @@ struct GTY(()) tree_decl_common {
/* In VAR_DECL, PARM_DECL and RESULT_DECL, this is DECL_RESTRICTED_P. */
unsigned decl_restricted_flag : 1;
+ /* In VAR_DECL and PARM_DECL set when the decl has been used except for
+ being set. */
+ unsigned decl_read_flag : 1;
+
/* Padding so that 'off_align' can be on a 32-bit boundary. */
- unsigned decl_common_unused : 2;
+ unsigned decl_common_unused : 1;
/* DECL_OFFSET_ALIGN, used only for FIELD_DECLs. */
unsigned int off_align : 8;
--- gcc/c-decl.c.jj 2009-11-04 08:16:04.000000000 +0100
+++ gcc/c-decl.c 2009-11-24 16:00:42.000000000 +0100
@@ -1164,14 +1164,20 @@ pop_scope (void)
case VAR_DECL:
/* Warnings for unused variables. */
- if (!TREE_USED (p)
+ if ((!TREE_USED (p) || !DECL_READ_P (p))
&& !TREE_NO_WARNING (p)
&& !DECL_IN_SYSTEM_HEADER (p)
&& DECL_NAME (p)
&& !DECL_ARTIFICIAL (p)
&& scope != file_scope
&& scope != external_scope)
- warning (OPT_Wunused_variable, "unused variable %q+D", p);
+ {
+ if (!TREE_USED (p))
+ warning (OPT_Wunused_variable, "unused variable %q+D", p);
+ else
+ warning (OPT_Wunused_variable,
+ "variable %q+D set but not used", p);
+ }
if (b->inner_comp)
{
@@ -2387,6 +2393,8 @@ merge_decls (tree newdecl, tree olddecl,
TREE_USED (newdecl) = 1;
else if (TREE_USED (newdecl))
TREE_USED (olddecl) = 1;
+ if (TREE_CODE (olddecl) == VAR_DECL || TREE_CODE (olddecl) == PARM_DECL)
+ DECL_READ_P (newdecl) |= DECL_READ_P (olddecl);
/* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
But preserve OLDDECL's DECL_UID, DECL_CONTEXT and
@@ -4377,6 +4385,7 @@ finish_decl (tree decl, location_t init_
/* Don't warn about decl unused; the cleanup uses it. */
TREE_USED (decl) = 1;
TREE_USED (cleanup_decl) = 1;
+ DECL_READ_P (decl) = 1;
push_cleanup (decl, cleanup, false);
}
@@ -4468,6 +4477,7 @@ build_compound_literal (location_t loc,
TREE_STATIC (decl) = (current_scope == file_scope);
DECL_CONTEXT (decl) = current_function_decl;
TREE_USED (decl) = 1;
+ DECL_READ_P (decl) = 1;
TREE_TYPE (decl) = type;
TREE_READONLY (decl) = TYPE_READONLY (type);
store_init_value (loc, decl, init, NULL_TREE);
--- gcc/c-common.c.jj 2009-11-09 13:30:10.000000000 +0100
+++ gcc/c-common.c 2009-11-24 15:40:55.000000000 +0100
@@ -6116,6 +6116,8 @@ handle_used_attribute (tree *pnode, tree
{
TREE_USED (node) = 1;
DECL_PRESERVE_P (node) = 1;
+ if (TREE_CODE (node) == VAR_DECL)
+ DECL_READ_P (node) = 1;
}
else
{
@@ -6142,7 +6144,12 @@ handle_unused_attribute (tree *node, tre
|| TREE_CODE (decl) == FUNCTION_DECL
|| TREE_CODE (decl) == LABEL_DECL
|| TREE_CODE (decl) == TYPE_DECL)
- TREE_USED (decl) = 1;
+ {
+ TREE_USED (decl) = 1;
+ if (TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == PARM_DECL)
+ DECL_READ_P (decl) = 1;
+ }
else
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
--- gcc/c-tree.h.jj 2009-11-04 08:16:04.000000000 +0100
+++ gcc/c-tree.h 2009-11-24 16:32:27.000000000 +0100
@@ -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);
--- gcc/c-typeck.c.jj 2009-11-04 08:16:04.000000000 +0100
+++ gcc/c-typeck.c 2009-11-25 09:15:56.000000000 +0100
@@ -1763,6 +1763,33 @@ function_to_pointer_conversion (location
return build_unary_op (loc, ADDR_EXPR, exp, 0);
}
+/* Mark EXP as read, not just set, for set but not used -Wunused
+ warning purposes. */
+
+void
+mark_exp_read (tree exp)
+{
+ switch (TREE_CODE (exp))
+ {
+ case VAR_DECL:
+ case PARM_DECL:
+ DECL_READ_P (exp) = 1;
+ break;
+ case ARRAY_REF:
+ case COMPONENT_REF:
+ case MODIFY_EXPR:
+ case REALPART_EXPR:
+ case IMAGPART_EXPR:
+ mark_exp_read (TREE_OPERAND (exp, 0));
+ break;
+ case COMPOUND_EXPR:
+ mark_exp_read (TREE_OPERAND (exp, 1));
+ break;
+ default:
+ break;
+ }
+}
+
/* Perform the default conversion of arrays and functions to pointers.
Return the result of converting EXP. For any other expression, just
return EXP.
@@ -1818,6 +1845,12 @@ default_function_array_conversion (locat
return exp;
}
+struct c_expr
+default_function_array_read_conversion (location_t loc, struct c_expr exp)
+{
+ mark_exp_read (exp.value);
+ return default_function_array_conversion (loc, exp);
+}
/* EXP is an expression of integer type. Apply the integer promotions
to it and return the promoted value. */
@@ -1879,6 +1912,8 @@ default_conversion (tree exp)
enum tree_code code = TREE_CODE (type);
tree promoted_type;
+ mark_exp_read (exp);
+
/* Functions and arrays have been converted during parsing. */
gcc_assert (code != FUNCTION_TYPE);
if (code == ARRAY_TYPE)
@@ -8738,6 +8773,7 @@ c_process_expr_stmt (location_t loc, tre
number, wrap the thing in a no-op NOP_EXPR. */
if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
{
+ mark_exp_read (expr);
expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
SET_EXPR_LOCATION (expr, loc);
}
--- gcc/c-parser.c.jj 2009-11-04 08:16:05.000000000 +0100
+++ gcc/c-parser.c 2009-11-24 18:49:20.000000000 +0100
@@ -3073,7 +3073,7 @@ c_parser_initializer (c_parser *parser)
ret = c_parser_expr_no_commas (parser, NULL);
if (TREE_CODE (ret.value) != STRING_CST
&& TREE_CODE (ret.value) != COMPOUND_LITERAL_EXPR)
- ret = default_function_array_conversion (loc, ret);
+ ret = default_function_array_read_conversion (loc, ret);
return ret;
}
}
@@ -3840,6 +3840,7 @@ c_parser_statement_after_labels (c_parse
else
{
struct c_expr expr = c_parser_expression_conv (parser);
+ mark_exp_read (expr.value);
stmt = c_finish_return (loc, expr.value, expr.original_type);
goto expect_semicolon;
}
@@ -4455,6 +4456,7 @@ c_parser_asm_operands (c_parser *parser,
}
loc = c_parser_peek_token (parser)->location;
expr = c_parser_expression (parser);
+ mark_exp_read (expr.value);
if (convert_p)
expr = default_function_array_conversion (loc, expr);
expr.value = c_fully_fold (expr.value, false, NULL);
@@ -4605,7 +4607,7 @@ c_parser_expr_no_commas (c_parser *parse
c_parser_consume_token (parser);
exp_location = c_parser_peek_token (parser)->location;
rhs = c_parser_expr_no_commas (parser, NULL);
- rhs = default_function_array_conversion (exp_location, rhs);
+ rhs = default_function_array_read_conversion (exp_location, rhs);
ret.value = build_modify_expr (op_location, lhs.value, lhs.original_type,
code, exp_location, rhs.value,
rhs.original_type);
@@ -4647,7 +4649,7 @@ c_parser_conditional_expression (c_parse
if (c_parser_next_token_is_not (parser, CPP_QUERY))
return cond;
cond_loc = c_parser_peek_token (parser)->location;
- cond = default_function_array_conversion (cond_loc, cond);
+ cond = default_function_array_read_conversion (cond_loc, cond);
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_COLON))
{
@@ -4691,7 +4693,7 @@ c_parser_conditional_expression (c_parse
{
location_t exp2_loc = c_parser_peek_token (parser)->location;
exp2 = c_parser_conditional_expression (parser, NULL);
- exp2 = default_function_array_conversion (exp2_loc, exp2);
+ exp2 = default_function_array_read_conversion (exp2_loc, exp2);
}
c_inhibit_evaluation_warnings -= cond.value == truthvalue_true_node;
ret.value = build_conditional_expr (colon_loc, cond.value,
@@ -4844,10 +4846,11 @@ c_parser_binary_expression (c_parser *pa
break; \
} \
stack[sp - 1].expr \
- = default_function_array_conversion (stack[sp - 1].loc, \
- stack[sp - 1].expr); \
+ = default_function_array_read_conversion (stack[sp - 1].loc, \
+ stack[sp - 1].expr); \
stack[sp].expr \
- = default_function_array_conversion (stack[sp].loc, stack[sp].expr); \
+ = default_function_array_read_conversion (stack[sp].loc, \
+ stack[sp].expr); \
stack[sp - 1].expr = parser_build_binary_op (stack[sp].loc, \
stack[sp].op, \
stack[sp - 1].expr, \
@@ -4952,8 +4955,8 @@ c_parser_binary_expression (c_parser *pa
{
case TRUTH_ANDIF_EXPR:
stack[sp].expr
- = default_function_array_conversion (stack[sp].loc,
- stack[sp].expr);
+ = default_function_array_read_conversion (stack[sp].loc,
+ stack[sp].expr);
stack[sp].expr.value = c_objc_common_truthvalue_conversion
(stack[sp].loc, default_conversion (stack[sp].expr.value));
c_inhibit_evaluation_warnings += (stack[sp].expr.value
@@ -4961,8 +4964,8 @@ c_parser_binary_expression (c_parser *pa
break;
case TRUTH_ORIF_EXPR:
stack[sp].expr
- = default_function_array_conversion (stack[sp].loc,
- stack[sp].expr);
+ = default_function_array_read_conversion (stack[sp].loc,
+ stack[sp].expr);
stack[sp].expr.value = c_objc_common_truthvalue_conversion
(stack[sp].loc, default_conversion (stack[sp].expr.value));
c_inhibit_evaluation_warnings += (stack[sp].expr.value
@@ -5032,7 +5035,7 @@ c_parser_cast_expression (c_parser *pars
{
location_t expr_loc = c_parser_peek_token (parser)->location;
expr = c_parser_cast_expression (parser, NULL);
- expr = default_function_array_conversion (expr_loc, expr);
+ expr = default_function_array_read_conversion (expr_loc, expr);
}
ret.value = c_cast_expr (cast_loc, type_name, expr.value);
ret.original_code = ERROR_MARK;
@@ -5085,23 +5088,24 @@ c_parser_unary_expression (c_parser *par
c_parser_consume_token (parser);
exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (exp_loc, op);
+ op = default_function_array_read_conversion (exp_loc, op);
return parser_build_unary_op (op_loc, PREINCREMENT_EXPR, op);
case CPP_MINUS_MINUS:
c_parser_consume_token (parser);
exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (exp_loc, op);
+ op = default_function_array_read_conversion (exp_loc, op);
return parser_build_unary_op (op_loc, PREDECREMENT_EXPR, op);
case CPP_AND:
c_parser_consume_token (parser);
- return parser_build_unary_op (op_loc, ADDR_EXPR,
- c_parser_cast_expression (parser, NULL));
+ op = c_parser_cast_expression (parser, NULL);
+ mark_exp_read (op.value);
+ return parser_build_unary_op (op_loc, ADDR_EXPR, op);
case CPP_MULT:
c_parser_consume_token (parser);
exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (exp_loc, op);
+ op = default_function_array_read_conversion (exp_loc, op);
ret.value = build_indirect_ref (op_loc, op.value, "unary *");
return ret;
case CPP_PLUS:
@@ -5112,25 +5116,25 @@ c_parser_unary_expression (c_parser *par
c_parser_consume_token (parser);
exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (exp_loc, op);
+ op = default_function_array_read_conversion (exp_loc, op);
return parser_build_unary_op (op_loc, CONVERT_EXPR, op);
case CPP_MINUS:
c_parser_consume_token (parser);
exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (exp_loc, op);
+ op = default_function_array_read_conversion (exp_loc, op);
return parser_build_unary_op (op_loc, NEGATE_EXPR, op);
case CPP_COMPL:
c_parser_consume_token (parser);
exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (exp_loc, op);
+ op = default_function_array_read_conversion (exp_loc, op);
return parser_build_unary_op (op_loc, BIT_NOT_EXPR, op);
case CPP_NOT:
c_parser_consume_token (parser);
exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (exp_loc, op);
+ op = default_function_array_read_conversion (exp_loc, op);
return parser_build_unary_op (op_loc, TRUTH_NOT_EXPR, op);
case CPP_AND_AND:
/* Refer to the address of a label as a pointer. */
@@ -5883,6 +5887,7 @@ c_parser_postfix_expression_after_primar
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
orig_expr = expr;
+ mark_exp_read (expr.value);
/* FIXME diagnostics: Ideally we want the FUNCNAME, not the
"(" after the FUNCNAME, which is what we have now. */
expr.value = build_function_call_vec (op_loc, expr.value, exprlist,
@@ -5965,7 +5970,7 @@ c_parser_postfix_expression_after_primar
case CPP_PLUS_PLUS:
/* Postincrement. */
c_parser_consume_token (parser);
- expr = default_function_array_conversion (expr_loc, expr);
+ expr = default_function_array_read_conversion (expr_loc, expr);
expr.value = build_unary_op (op_loc,
POSTINCREMENT_EXPR, expr.value, 0);
expr.original_code = ERROR_MARK;
@@ -5974,7 +5979,7 @@ c_parser_postfix_expression_after_primar
case CPP_MINUS_MINUS:
/* Postdecrement. */
c_parser_consume_token (parser);
- expr = default_function_array_conversion (expr_loc, expr);
+ expr = default_function_array_read_conversion (expr_loc, expr);
expr.value = build_unary_op (op_loc,
POSTDECREMENT_EXPR, expr.value, 0);
expr.original_code = ERROR_MARK;
@@ -6052,7 +6057,7 @@ c_parser_expr_list (c_parser *parser, bo
expr = c_parser_expr_no_commas (parser, NULL);
if (convert_p)
- expr = default_function_array_conversion (loc, expr);
+ expr = default_function_array_read_conversion (loc, expr);
if (fold_p)
expr.value = c_fully_fold (expr.value, false, NULL);
VEC_quick_push (tree, ret, expr.value);
@@ -6064,7 +6069,7 @@ c_parser_expr_list (c_parser *parser, bo
loc = c_parser_peek_token (parser)->location;
expr = c_parser_expr_no_commas (parser, NULL);
if (convert_p)
- expr = default_function_array_conversion (loc, expr);
+ expr = default_function_array_read_conversion (loc, expr);
if (fold_p)
expr.value = c_fully_fold (expr.value, false, NULL);
VEC_safe_push (tree, gc, ret, expr.value);
@@ -7887,7 +7892,7 @@ c_parser_omp_atomic (location_t loc, c_p
{
location_t rhs_loc = c_parser_peek_token (parser)->location;
rhs_expr = c_parser_expression (parser);
- rhs_expr = default_function_array_conversion (rhs_loc, rhs_expr);
+ rhs_expr = default_function_array_read_conversion (rhs_loc, rhs_expr);
}
rhs = rhs_expr.value;
rhs = c_fully_fold (rhs, false, NULL);
@@ -8034,7 +8039,8 @@ c_parser_omp_for_loop (location_t loc,
init_loc = c_parser_peek_token (parser)->location;
init_exp = c_parser_expr_no_commas (parser, NULL);
- init_exp = default_function_array_conversion (init_loc, init_exp);
+ init_exp = default_function_array_read_conversion (init_loc,
+ init_exp);
init = build_modify_expr (init_loc, decl, decl_exp.original_type,
NOP_EXPR, init_loc, init_exp.value,
init_exp.original_type);
--- gcc/testsuite/gcc.dg/Wunused-var-1.c.jj 2009-11-24 17:23:59.000000000 +0100
+++ gcc/testsuite/gcc.dg/Wunused-var-1.c 2009-11-25 09:20:42.000000000 +0100
@@ -0,0 +1,159 @@
+/* { dg-do compile } */
+/* { dg-options "-Wunused" } */
+
+void
+f1 (void)
+{
+ int a; /* { dg-warning "set but not used" } */
+ int b;
+ int c;
+ c = 1;
+ a = b = c;
+}
+
+void
+f2 (int x)
+{
+ int a; /* { dg-warning "set but not used" } */
+ int b;
+ int c; /* { dg-warning "set but not used" } */
+ c = (a = x, b = x);
+}
+
+int
+f3 (int x)
+{
+ int a;
+ return a = x;
+}
+
+int
+f4 (int x)
+{
+ int a;
+ a = x;
+ return a;
+}
+
+void
+f5 (int x)
+{
+ int a[2]; /* { dg-warning "set but not used" } */
+ int b;
+ int *c, d[2];
+ c = d;
+ b = x;
+ a[b] = 1;
+ c[b] = 1;
+}
+
+int
+f6 (int x)
+{
+ int a[2];
+ int b;
+ b = x;
+ a[b] = 1;
+ return a[b];
+}
+
+void
+f7 (int x, int *p)
+{
+ int *a[2];
+ a[x] = p;
+ a[x][x] = x;
+}
+
+struct S { int i; };
+
+void
+f8 (void)
+{
+ struct S s; /* { dg-warning "set but not used" } */
+ s.i = 6;
+}
+
+int
+f9 (void)
+{
+ struct S s;
+ s.i = 6;
+ return s.i;
+}
+
+struct S
+f10 (void)
+{
+ struct S s;
+ s.i = 6;
+ return s;
+}
+
+extern int foo11 (int *);
+
+void
+f11 (void)
+{
+ int a[2];
+ foo11 (a);
+}
+
+void
+f12 (void)
+{
+ int a;
+ a = 1;
+ a; /* { dg-warning "statement with no effect" } */
+}
+
+void
+f13 (void (*x) (void))
+{
+ void (*a) (void);
+ a = x;
+ a ();
+}
+
+void
+f14 (void (*x) (void))
+{
+ void (*a) (void); /* { dg-warning "set but not used" } */
+ a = x;
+}
+
+extern void foo15 (int *);
+
+void
+f15 (void)
+{
+ int a[10];
+ int *b = a + 2;
+ foo15 (b);
+}
+
+extern void foo16 (int **);
+
+void
+f16 (void)
+{
+ int a[10];
+ int *b[] = { a, a + 2 };
+ foo16 (b);
+}
+
+void
+f17 (int x)
+{
+ long a; /* { dg-warning "set but not used" } */
+ int b;
+ a = b = x;
+}
+
+void
+f18 (int x)
+{
+ int a; /* { dg-warning "set but not used" } */
+ int b;
+ a = (char) (b = x);
+}
--- gcc/testsuite/gcc.dg/Wunused-var-2.c.jj 2009-11-24 18:02:41.000000000 +0100
+++ gcc/testsuite/gcc.dg/Wunused-var-2.c 2009-11-24 18:35:04.000000000 +0100
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-Wunused" } */
+
+int
+f1 (void)
+{
+ int c = ({
+ int a;
+ a = 1;
+ a; });
+ return c;
+}
+
+void
+f2 (void)
+{
+ int f;
+ f = 0;
+ __asm__ __volatile__ ("" : "+r" (f));
+}
--- gcc/testsuite/gcc.dg/Wunused-var-3.c.jj 2009-11-25 09:18:18.000000000 +0100
+++ gcc/testsuite/gcc.dg/Wunused-var-3.c 2009-11-25 09:18:07.000000000 +0100
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-Wunused" } */
+
+void
+f1 (void)
+{
+ _Complex int a; /* { dg-warning "set but not used" } */
+ _Complex double b; /* { dg-warning "set but not used" } */
+ __real__ a = 1;
+ __imag__ a = 2;
+ __real__ b = 3.0;
+ __imag__ b = 4.0;
+}
+
+int
+f2 (void)
+{
+ _Complex int a;
+ _Complex double b;
+ __real__ a = 1;
+ __imag__ a = 2;
+ __real__ b = 3.0;
+ __imag__ b = 4.0;
+ return __real__ a + __imag__ b;
+}
+
+_Complex double
+f3 (void)
+{
+ _Complex int a;
+ _Complex double b;
+ __real__ a = 1;
+ __imag__ a = 2;
+ __real__ b = 3.0;
+ __imag__ b = 4.0;
+ return a + b;
+}
[-- Attachment #3: N1 --]
[-- Type: text/plain, Size: 36390 bytes --]
gcc/calls.c:260:7: warning: variable âstruct_value_size_rtxâ set but not used
gcc/cfgloopmanip.c:544:15: warning: variable âsucc_bbâ set but not used
gcc/cfgloopmanip.c:631:7: warning: variable âfreqâ set but not used
gcc/cfgloopmanip.c:632:13: warning: variable âcntâ set but not used
gcc/cfgrtl.c:1509:12: warning: variable âbb_noteâ set but not used
gcc/config/i386/i386.c:24723:31: warning: variable âsse_fpmath_classesâ set but not used
gcc/config/i386/i386.c:8847:12: warning: variable âinsnâ set but not used
gcc/config/i386/i386.md:10039:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:10040:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:12941:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:12942:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:13164:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:13165:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:13915:7: warning: variable âoperand3â set but not used
gcc/config/i386/i386.md:13981:7: warning: variable âoperand3â set but not used
gcc/config/i386/i386.md:14043:7: warning: variable âoperand3â set but not used
gcc/config/i386/i386.md:14318:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:14320:7: warning: variable âoperand3â set but not used
gcc/config/i386/i386.md:14324:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:14349:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:14351:7: warning: variable âoperand3â set but not used
gcc/config/i386/i386.md:14355:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:15265:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:15268:7: warning: variable âoperand3â set but not used
gcc/config/i386/i386.md:15314:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:15316:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:15636:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:15637:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:15638:7: warning: variable âoperand3â set but not used
gcc/config/i386/i386.md:15639:7: warning: variable âoperand4â set but not used
gcc/config/i386/i386.md:15695:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:15696:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:15697:7: warning: variable âoperand3â set but not used
gcc/config/i386/i386.md:16435:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:16508:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:16518:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:16546:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:16547:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:16559:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:17567:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:17839:7: warning: variable âoperand4â set but not used
gcc/config/i386/i386.md:18101:7: warning: variable âoperand4â set but not used
gcc/config/i386/i386.md:19216:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:19303:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:19437:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:19519:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:19520:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:19524:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20149:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20172:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20186:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20202:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20235:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20256:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20313:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:20317:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20337:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20391:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20394:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20417:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20419:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20431:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:20434:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20443:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20449:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:20452:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20460:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:20463:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20470:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:20473:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20637:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20765:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20769:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20784:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20796:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:20858:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:20877:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:20893:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:20909:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:20913:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:2329:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:2592:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:2593:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:2599:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:2607:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:2608:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:2807:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:2827:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:2855:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:2973:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:3019:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:3510:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:3532:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:3649:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:3670:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:3673:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:3710:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:3855:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:3940:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:3991:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:3992:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:3993:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:3994:7: warning: variable âoperand3â set but not used
gcc/config/i386/i386.md:4034:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:4035:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:4036:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:4037:7: warning: variable âoperand3â set but not used
gcc/config/i386/i386.md:4043:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:4045:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:4090:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:4092:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:4188:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:4217:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:4246:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:4332:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:4340:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:4352:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:4353:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:4494:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:4495:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:4895:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:4899:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:4926:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:4930:16: warning: variable â_regs_allocatedâ set but not used
gcc/config/i386/i386.md:5020:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:5027:7: warning: variable âoperand2â set but not used
gcc/config/i386/i386.md:5120:7: warning: variable âoperand4â set but not used
gcc/config/i386/i386.md:5747:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:5796:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:5843:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:5862:7: warning: variable âoperand1â set but not used
gcc/config/i386/i386.md:7838:7: warning: variable âoperand3â set but not used
gcc/config/i386/i386.md:7900:7: warning: variable âoperand3â set but not used
gcc/config/i386/i386.md:8557:7: warning: variable âoperand0â set but not used
gcc/config/i386/i386.md:8608:7: warning: variable âoperand0â set but not used
gcc/config/i386/sse.md:2061:7: warning: variable âoperand2â set but not used
gcc/config/i386/sse.md:3393:7: warning: variable âoperand2â set but not used
gcc/config/i386/sse.md:3443:7: warning: variable âoperand2â set but not used
gcc/cp/class.c:6062:7: warning: variable âis_referenceâ set but not used
gcc/cp/class.c:8046:8: warning: variable âbasetypeâ set but not used
gcc/cp/cp-gimplify.c:432:8: warning: variable âslotâ set but not used
gcc/cp/decl.c:1038:8: warning: variable ânameâ set but not used
gcc/cp/decl.c:4074:8: warning: variable âtypeâ set but not used
gcc/cp/decl.c:524:7: warning: variable âreal_functionbodyâ set but not used
gcc/cp/g++spec.c:63:7: warning: variable âsaw_verbose_flagâ set but not used
gcc/cp/init.c:2669:8: warning: variable âsizeâ set but not used
gcc/cp/mangle.c:2812:7: warning: variable âparm_levelâ set but not used
gcc/cp/mangle.c:2813:8: warning: variable âparm_typeâ set but not used
gcc/cp/parser.c:10638:7: warning: variable âparameter_listâ set but not used
gcc/cp/parser.c:10779:55: warning: variable âtokenâ set but not used
gcc/cp/parser.c:11504:13: warning: variable âtokenâ set but not used
gcc/cp/parser.c:11984:12: warning: variable âidâ set but not used
gcc/cp/parser.c:13788:13: warning: variable âtokenâ set but not used
gcc/cp/parser.c:15000:8: warning: variable âgreater_than_is_operator_pâ set but not used
gcc/cp/parser.c:18209:9: warning: variable âmemberâ set but not used
gcc/cp/parser.c:23111:8: warning: variable âerror_occurredâ set but not used
gcc/cppspec.c:81:14: warning: variable âis_cpp_driverâ set but not used
gcc/cp/pt.c:7992:8: warning: variable âfirst_arg_packâ set but not used
gcc/cp/typeck2.c:658:8: warning: variable âwas_declâ set but not used
gcc/cp/typeck.c:3024:8: warning: variable ânameâ set but not used
gcc/dominance.c:742:7: warning: variable ânâ set but not used
gcc/dwarf2out.c:11264:7: warning: variable âidxâ set but not used
gcc/dwarf2out.c:15724:28: warning: variable âstatusâ set but not used
gcc/dwarf2out.c:17965:12: warning: variable âfieldâ set but not used
gcc/expr.c:2689:47: warning: variable âval_treeâ set but not used
gcc/expr.c:5765:17: warning: variable âwidth_maskâ set but not used
gcc/expr.c:7243:26: warning: variable âtreeop2â set but not used
gcc/fortran/arith.c:2671:7: warning: variable âlenâ set but not used
gcc/fortran/arith.c:2695:7: warning: variable âlenâ set but not used
gcc/fortran/arith.c:2744:7: warning: variable âlenâ set but not used
gcc/fortran/data.c:49:11: warning: variable âreâ set but not used
gcc/fortran/decl.c:1659:9: warning: variable âold_locusâ set but not used
gcc/fortran/expr.c:2081:28: warning: variable âinquiry_func_f2003â set but not used
gcc/fortran/expr.c:2165:29: warning: variable âtrans_func_f2003â set but not used
gcc/fortran/intrinsic.c:4057:16: warning: variable âfrom_tsâ set but not used
gcc/fortran/io.c:4063:9: warning: variable âlocâ set but not used
gcc/fortran/iresolve.c:2576:33: warning: variable âstatusâ set but not used
gcc/fortran/iresolve.c:3264:13: warning: variable âstatusâ set but not used
gcc/fortran/match.c:2904:15: warning: variable âvarâ set but not used
gcc/fortran/matchexp.c:152:9: warning: variable âwhereâ set but not used
gcc/fortran/misc.c:160:15: warning: variable âbuffer1â set but not used
gcc/fortran/module.c:3980:15: warning: variable ânuseâ set but not used
gcc/fortran/module.c:744:15: warning: variable âcâ set but not used
gcc/fortran/parse.c:1940:68: warning: variable âerror_flagâ set but not used
gcc/fortran/parse.c:1943:15: warning: variable âderived_symâ set but not used
gcc/fortran/parse.c:2108:7: warning: variable âerror_flagâ set but not used
gcc/fortran/resolve.c:11696:15: warning: variable âvalue_nameâ set but not used
gcc/fortran/resolve.c:5128:15: warning: variable âtbp_symâ set but not used
gcc/fortran/resolve.c:7616:19: warning: variable âassign_procâ set but not used
gcc/fortran/trans-array.c:3462:12: warning: variable âarefâ set but not used
gcc/fortran/trans-array.c:3464:7: warning: variable âtemp_dimâ set but not used
gcc/fortran/trans-array.c:3560:7: warning: variable âdimâ set but not used
gcc/fortran/trans-array.c:3565:8: warning: variable âlenâ set but not used
gcc/fortran/trans-array.c:6183:11: warning: variable âheadâ set but not used
gcc/fortran/trans-common.c:639:21: warning: variable âoffsetâ set but not used
gcc/fortran/trans-common.c:667:14: warning: variable âvalueâ set but not used
gcc/fortran/trans-expr.c:359:8: warning: variable âvarâ set but not used
gcc/fortran/trans-intrinsic.c:4093:8: warning: variable âsourceâ set but not used
gcc/fortran/trans-intrinsic.c:4231:8: warning: variable âstrideâ set but not used
gcc/fortran/trans-intrinsic.c:5068:22: warning: variable âisymâ set but not used
gcc/fortran/trans-intrinsic.c:835:21: warning: variable âcond2â set but not used
gcc/fortran/trans-openmp.c:1137:13: warning: variable âoutermostâ set but not used
gcc/fortran/trans-openmp.c:703:48: warning: variable âold_clausesâ set but not used
gcc/fortran/trans-types.c:2493:18: warning: variable âoffset_offâ set but not used
gcc/gcc.c:3133:6: warning: variable âstatusâ set but not used
gcc/gcse.c:4887:14: warning: variable ânew_rtxâ set but not used
gcc/graphite-clast-to-gimple.c:1157:8: warning: variable ânew_scop_exit_edgeâ set but not used
gcc/graphite-sese-to-poly.c:1745:7: warning: variable ânum_componentâ set but not used
gcc/haifa-sched.c:2506:51: warning: variable âpointsâ set but not used
gcc/haifa-sched.c:4465:8: warning: variable âeâ set but not used
gcc/ipa-pure-const.c:263:21: warning: variable âavailâ set but not used
gcc/ipa-struct-reorg.c:3438:8: warning: variable âfndeclâ set but not used
gcc/ira-color.c:1479:7: warning: variable âhard_regs_numâ set but not used
gcc/ira-costs.c:1537:21: warning: variable âmodeâ set but not used
gcc/ira-lives.c:807:22: warning: variable âcover_classâ set but not used
gcc/loop-unswitch.c:395:11: warning: variable âzero_bitmapâ set but not used
gcc/lower-subreg.c:1177:12: warning: variable ânextâ set but not used
gcc/lto/lto-lang.c:288:26: warning: variable âattr_arg_numâ set but not used
gcc/lto-streamer-in.c:2600:8: warning: variable âend_markerâ set but not used
gcc/matrix-reorg.c:1576:15: warning: variable âbb_level_0â set but not used
gcc/matrix-reorg.c:1857:12: warning: variable âuse_stmtâ set but not used
gcc/matrix-reorg.c:1921:10: warning: variable âd_type_sizeâ set but not used
gcc/matrix-reorg.c:1921:23: warning: variable âd_type_size_kâ set but not used
gcc/matrix-reorg.c:824:16: warning: variable âmalloc_fnameâ set but not used
gcc/omega.c:1981:17: warning: variable ânâ set but not used
gcc/omega.c:3726:11: warning: variable âneweqnsâ set but not used
gcc/omp-low.c:4650:40: warning: variable âl1â set but not used
gcc/omp-low.c:524:10: warning: variable âpar_stmtâ set but not used
gcc/omp-low.c:6026:41: warning: variable âilistâ set but not used
gcc/optabs.c:1722:11: warning: variable âequiv_valueâ set but not used
gcc/optabs.c:3906:7: warning: variable âprevâ set but not used
gcc/optabs.c:6204:21: warning: variable âint_modeâ set but not used
gcc/postreload.c:410:25: warning: variable âmodeâ set but not used
gcc/recog.c:1499:7: warning: variable ânoperandsâ set but not used
gcc/regmove.c:608:7: warning: variable âinsn_uidâ set but not used
gcc/regmove.c:609:7: warning: variable âmove_uidâ set but not used
gcc/regrename.c:227:20: warning: variable âregs_seenâ set but not used
gcc/regrename.c:805:11: warning: variable âicodeâ set but not used
gcc/sel-sched.c:1860:14: warning: variable âtwinâ set but not used
gcc/sel-sched.c:2405:16: warning: variable âdsâ set but not used
gcc/sel-sched.c:4211:10: warning: variable âcur_insnâ set but not used
gcc/sel-sched.c:4211:20: warning: variable âmin_spec_insnâ set but not used
gcc/sel-sched.c:4381:32: warning: variable âavail_nâ set but not used
gcc/sel-sched-ir.c:5846:7: warning: variable ânew_regionsâ set but not used
gcc/tree.c:3703:8: warning: variable âconstantâ set but not used
gcc/tree.c:3744:18: warning: variable âread_onlyâ set but not used
gcc/tree.c:3744:8: warning: variable âconstantâ set but not used
gcc/tree.c:3771:18: warning: variable âread_onlyâ set but not used
gcc/tree.c:3771:8: warning: variable âconstantâ set but not used
gcc/tree.c:3799:18: warning: variable âread_onlyâ set but not used
gcc/tree.c:3799:8: warning: variable âconstantâ set but not used
gcc/tree-call-cdce.c:460:8: warning: variable âbase_nmâ set but not used
gcc/tree-call-cdce.c:551:22: warning: variable âecâ set but not used
gcc/tree-cfg.c:1630:15: warning: variable âstmtâ set but not used
gcc/tree-complex.c:437:12: warning: variable âinner_typeâ set but not used
gcc/tree-dfa.c:619:13: warning: variable âv_annâ set but not used
gcc/tree-eh.c:3396:11: warning: variable âuse_stmtâ set but not used
gcc/tree-flow-inline.h:928:8: warning: variable âtâ set but not used
gcc/tree-inline.c:259:8: warning: variable âfnâ set but not used
gcc/tree-inline.c:3509:8: warning: variable âretvarâ set but not used
gcc/tree-inline.c:3984:8: warning: variable âprev_fnâ set but not used
gcc/tree-inline.c:593:8: warning: variable âfnâ set but not used
gcc/tree-loop-distribution.c:342:11: warning: variable âstmtâ set but not used
gcc/tree-loop-distribution.c:524:7: warning: variable âhas_upstream_mem_write_pâ set but not used
gcc/tree-optimize.c:381:23: warning: variable ânodeâ set but not used
gcc/tree-outof-ssa.c:528:19: warning: variable âlocusâ set but not used
gcc/tree-outof-ssa.c:546:19: warning: variable âlocusâ set but not used
gcc/tree-parloops.c:1408:18: warning: variable âresâ set but not used
gcc/tree-parloops.c:1534:16: warning: variable ânloopâ set but not used
gcc/tree-parloops.c:865:17: warning: variable âaddr_typeâ set but not used
gcc/tree-predcom.c:1882:8: warning: variable âeâ set but not used
gcc/tree-ssa-alias.c:770:17: warning: variable âsize1â set but not used
gcc/tree-ssa-alias.c:770:29: warning: variable âsize2â set but not used
gcc/tree-ssa-dce.c:875:15: warning: variable âuse_stmtâ set but not used
gcc/tree-ssa-loop-niter.c:76:8: warning: variable ânegateâ set but not used
gcc/tree-ssa-operands.c:1335:10: warning: variable âuse_stmtâ set but not used
gcc/tree-ssa-operands.c:656:13: warning: variable âv_annâ set but not used
gcc/tree-ssa-sccvn.c:1026:25: warning: variable âsizeâ set but not used
gcc/tree-ssa-sink.c:276:18: warning: variable âcodeâ set but not used
gcc/tree-ssa-structalias.c:1357:9: warning: variable âhave_ref_nodeâ set but not used
gcc/tree-ssa-structalias.c:3286:12: warning: variable âlhsbaseâ set but not used
gcc/tree-ssa-structalias.c:3286:21: warning: variable ârhsbaseâ set but not used
gcc/tree-ssa-structalias.c:3643:13: warning: variable ârhstypeâ set but not used
gcc/tree-ssa-structalias.c:5684:20: warning: variable âvaridâ set but not used
gcc/tree-ssa-threadupdate.c:638:21: warning: variable âlocal_infoâ set but not used
gcc/tree-vect-data-refs.c:1888:19: warning: variable âbbâ set but not used
gcc/tree-vect-data-refs.c:2767:8: warning: variable âscalar_destâ set but not used
gcc/tree-vect-data-refs.c:3385:8: warning: variable âinvariant_in_outerloopâ set but not used
gcc/tree-vect-loop.c:2893:25: warning: variable âbytesizeâ set but not used
gcc/tree-vect-loop.c:892:12: warning: variable âbackedgeâ set but not used
gcc/tree-vect-loop-manip.c:2330:16: warning: variable ânloopâ set but not used
gcc/tree-vect-patterns.c:459:8: warning: variable âtypeâ set but not used
gcc/tree-vect-patterns.c:815:10: warning: variable âstmtâ set but not used
gcc/tree-vect-slp.c:1644:10: warning: variable âgroup_sizeâ set but not used
gcc/tree-vect-slp.c:1644:30: warning: variable âdr_chain_sizeâ set but not used
gcc/tree-vect-slp.c:882:42: warning: variable âncopiesâ set but not used
gcc/tree-vect-stmts.c:1551:8: warning: variable âexprâ set but not used
gcc/tree-vect-stmts.c:1932:8: warning: variable âshift_pâ set but not used
gcc/tree-vect-stmts.c:2896:17: warning: variable âfirst_stmt_vinfoâ set but not used
gcc/tree-vrp.c:3914:8: warning: variable âfoundâ set but not used
gcc/tree-vrp.c:5225:9: warning: variable âuse_stmtâ set but not used
gcc/tree-vrp.c:6000:24: warning: variable ânâ set but not used
gcc/value-prof.c:1370:8: warning: variable âvalueâ set but not used
gcc/value-prof.c:1596:26: warning: variable âfcodeâ set but not used
gcc/value-prof.c:962:26: warning: variable âvalueâ set but not used
gcc/varasm.c:4646:15: warning: variable âvalueâ set but not used
libgcc/config/libbid/bid128_div.c:1406:51: warning: variable âQlâ set but not used
libgcc/config/libbid/bid128_div.c:39:51: warning: variable âQlâ set but not used
libgcc/config/libbid/bid128_div.c:490:51: warning: variable âQlâ set but not used
libgcc/config/libbid/bid128_div.c:949:51: warning: variable âQlâ set but not used
libgcc/config/libbid/bid64_div.c:1374:51: warning: variable âQlâ set but not used
libgcc/config/libbid/bid64_div.c:523:51: warning: variable âQlâ set but not used
libgcc/config/libbid/bid64_div.c:937:51: warning: variable âQlâ set but not used
libgcc/gcc/config/soft-fp/unordtf2.c:36:1: warning: variable âA_sâ set but not used
libgcc/gcc/config/soft-fp/unordtf2.c:37:1: warning: variable âB_sâ set but not used
libgcc/gcc/libgcov.c:678:13: warning: variable âlastâ set but not used
libgcc/gcc/unwind-c.c:123:53: warning: variable âaction_recordâ set but not used
libgfortran/generated/maxloc1_16_i16.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_16_i1.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_16_i2.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_16_i4.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_16_i8.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_16_r10.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_16_r4.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_16_r8.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_4_i16.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_4_i1.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_4_i2.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_4_i4.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_4_i8.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_4_r10.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_4_r4.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_4_r8.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_8_i16.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_8_i1.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_8_i2.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_8_i4.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_8_i8.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_8_r10.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_8_r4.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxloc1_8_r8.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxval_i16.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxval_i1.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxval_i2.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxval_i4.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxval_i8.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxval_r10.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxval_r4.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/maxval_r8.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_16_i16.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_16_i1.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_16_i2.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_16_i4.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_16_i8.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_16_r10.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_16_r4.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_16_r8.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_4_i16.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_4_i1.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_4_i2.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_4_i4.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_4_i8.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_4_r10.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_4_r4.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_4_r8.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_8_i16.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_8_i1.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_8_i2.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_8_i4.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_8_i8.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_8_r10.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_8_r4.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minloc1_8_r8.c:442:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minval_i16.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minval_i1.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minval_i2.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minval_i4.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minval_i8.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minval_r10.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minval_r4.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/minval_r8.c:429:14: warning: variable âsstrideâ set but not used
libgfortran/generated/product_c10.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/product_c4.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/product_c8.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/product_i16.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/product_i1.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/product_i2.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/product_i4.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/product_i8.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/product_r10.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/product_r4.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/product_r8.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/sum_c10.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/sum_c4.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/sum_c8.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/sum_i16.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/sum_i1.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/sum_i2.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/sum_i4.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/sum_i8.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/sum_r10.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/sum_r4.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/generated/sum_r8.c:387:14: warning: variable âsstrideâ set but not used
libgfortran/intrinsics/pack_generic.c:90:7: warning: variable âzero_sizedâ set but not used
libgfortran/intrinsics/unpack_generic.c:406:14: warning: variable âsizeâ set but not used
libgfortran/io/unix.c:1290:12: warning: variable âidâ set but not used
libgfortran/io/write.c:1430:21: warning: variable âlengthâ set but not used
libiberty/regex.c:7143:22: warning: variable âpdummyâ set but not used
libiberty/regex.c:7144:27: warning: variable âsdummyâ set but not used
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] Add set but not used warning support for the C FE (PR c/18624)
2009-11-25 9:12 [RFC PATCH] Add set but not used warning support for the C FE (PR c/18624) Jakub Jelinek
@ 2009-11-25 16:04 ` Joseph S. Myers
0 siblings, 0 replies; 4+ messages in thread
From: Joseph S. Myers @ 2009-11-25 16:04 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Richard Guenther, gcc-patches
The C front-end changes are OK once the warnings that would be errors with
-Werror in a default bootstrap are fixed.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] Add set but not used warning support for the C FE (PR c/18624)
2009-11-25 11:02 d binderman
@ 2009-11-25 16:22 ` Jakub Jelinek
0 siblings, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2009-11-25 16:22 UTC (permalink / raw)
To: d binderman; +Cc: rguenther, gcc-patches, joseph
On Wed, Nov 25, 2009 at 10:44:56AM +0000, d binderman wrote:
> >attached is a list of these warnings during bootstrap
>
> There are over 400 of them. It looks to me like all of these need fixing,
> to get this patch into the mainstream bootstrap. That's quite a lot of work.
True, but e.g. many of them are solvable in just one spot (e.g. all
_operandN unused in insn-emit.c is one fix, etc.), and some aren't in files
compiled with -Werror (e.g. libbid, soft-fp).
> >I wonder whether we want to control this warning with a separate -Wunused-* switch
>
> If you invent a new name, then folks initially won't use it.
Having a separate option to control it has the advantage that it can be
separately turned off or on. It could certainly be included in -Wunused,
like -Wunused-variables and -Wunused-parameters is (-Wunused-set-variables
and -Wunused-set-parameters ??).
> >If anyone has suggestions what else should be tested in
> >the testsuite of this warning
>
> How about this one
>
> static int fred;
>
> void
> f()
> {
> fred = 1;
> }
> /*no more uses of fred */
>
> where file static data is set but not used, might also be worth a warning,
> even if only with -Os.
This would need to wait until all FEs set the flag, because the checking
would need to be performed again in generic code.
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] Add set but not used warning support for the C FE (PR c/18624)
@ 2009-11-25 11:02 d binderman
2009-11-25 16:22 ` Jakub Jelinek
0 siblings, 1 reply; 4+ messages in thread
From: d binderman @ 2009-11-25 11:02 UTC (permalink / raw)
To: jakub; +Cc: rguenther, gcc-patches, joseph
Hello there,
Jakub wrote:
>The attached patch is my initial attempt at adding the set but not used warning
Excellent work.
>attached is a list of these warnings during bootstrap
There are over 400 of them. It looks to me like all of these need fixing,
to get this patch into the mainstream bootstrap. That's quite a lot of work.
>I wonder whether we want to control this warning with a separate -Wunused-* switch
If you invent a new name, then folks initially won't use it.
It will get a lot more use if it goes into -Wunused or even -Wall.
It depends how soon you want to go mainstream with it.
>If anyone has suggestions what else should be tested in
>the testsuite of this warning
How about this one
static int fred;
void
f()
{
fred = 1;
}
/*no more uses of fred */
where file static data is set but not used, might also be worth a warning,
even if only with -Os.
I'd be happy for your current patch to go ahead as is, but if it's not much extra work
it might be worth enhancing your patch to warn for the above source code too.
Regards
David Binderman
_________________________________________________________________
Use Hotmail to send and receive mail from your different email accounts
http://clk.atdmt.com/UKM/go/186394592/direct/01/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-11-25 16:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-25 9:12 [RFC PATCH] Add set but not used warning support for the C FE (PR c/18624) Jakub Jelinek
2009-11-25 16:04 ` Joseph S. Myers
2009-11-25 11:02 d binderman
2009-11-25 16:22 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).