[patch] [C/C++] Add a new warning flag -Wself-assign
Le-Chun Wu
lcwu@google.com
Tue Jun 29 19:00:00 GMT 2010
Ping?
On Thu, Jun 24, 2010 at 3:54 PM, Le-Chun Wu <lcwu@google.com> wrote:
> Attached please find the revised patch for the new flag -Wself-assign.
> Comparing with the previous patch, this one puts -Winit-self back but
> keeps it as a no-op, and resurrects the -Winit-self test cases to make
> sure the flag is still accepted by GCC. It also fixes the following
> self-assign/self-init warnings in GCC source code when bootstrapping.
> (The flag actually identified a real bug/typo in cgraphunit.c. Yeah!
> :-)) Relevant maintainers of these files are also cc'ed in this email.
>
> * dbxout.c (DEBUGGER_ARG_OFFSET):
> * omega.c (omega_eliminate_redundant)
> * tree-ssa-ccp.c (ccp_lattice_meet)
> * cgraphunit.c (cgraph_copy_node_for_versioning)
> * config/i386/i386.c (ix86_vectorize_builtin_vec_perm)
>
> Again, bootstrapped and tested on x86_64-linux-gnu. OK for trunk?
>
> Le-chun
>
> gcc/ChangeLog
>
> 2010-06-24 Le-Chun Wu <lcwu@google.com>
>
> * doc/invoke.texi (-Wall): Include -Wself-assign.
> (-Wself-assign): Documentation for the new flag.
> (-Winit-self): Remove.
> (-Wuninitialized): Remove mention of -Winit-self.
> (-Wunused-variable): Mention of new workaround.
> * tree.h (tree_base): Add a new tree_base flag indicating if an
> expression is the result of constant-folding.
> (operand_equal_flag): Add two new flags for operand_equal_p routine.
> * fold-const.c (operand_equal_p): Support comparison of NULL
> operands and operands without types.
> (set_expr_folded_flag): New helper function.
> (fold_unary_loc_1): Renamed from fold_unary_loc.
> (fold_unary_loc): A wrapper around fold_unary_loc_1 function that sets
> the EXPR_FOLDED flag of the folded expression if folding is
> successful.
> (fold_binary_loc_1): Renamed from fold_binary_loc.
> (fold_binary_loc): A wrapper around fold_binary_loc_1 function that
> sets the EXPR_FOLDED flag of the folded expression if folding is
> successful.
> (fold_ternary_loc_1): Renamed from fold_ternary_loc.
> (fold_ternary_loc): A wrapper around fold_ternary_loc_1 function that
> sets the EXPR_FOLDED flag of the folded expression if folding is
> successful.
> * c-parser.c (c_parser_declaration_or_fndef): Check for
> self-assign after parsing variable initialization.
> (c_parser_expr_no_commas): Check for self-assign after parsing an
> assignment.
> * dbxout.c (DEBUGGER_ARG_OFFSET): Change OFFSET to OFFSET+0 to avoid
> self-assign warning.
> * omega.c (omega_eliminate_redundant): Remove a self-assign statement.
> * tree-ssa-ccp.c (ccp_lattice_meet): Remove a self-assign statement
> and an unnecessary assignment.
> * cgraphunit.c (cgraph_copy_node_for_versioning): Fix a typo detected
> by -Wself-assign.
> * config/i386/i386.c (ix86_vectorize_builtin_vec_perm): Remove
> unnecessary self-init.
>
> gcc/c-family/ChangeLog
>
> 2010-06-24 Le-Chun Wu <lcwu@google.com>
>
> * gcc/c-family/c-gimplify.c (c_gimplify_expr): Remove support for
> -Winit-self.
> * gcc/c-family/c.opt: Make -Winit-self a no-op and add -Wself-assign.
> * gcc/c-family/c-opts.c : Enable -Wself-assign by -Wall.
> * gcc/c-family/c-common.c (check_for_self_assign): New function.
> * gcc/c-family/c-common.h: Add prototype for check_for_self_assign.
>
> gcc/cp/ChangeLog
>
> 2010-06-24 Le-Chun Wu <lcwu@google.com>
>
> * init.c (perform_member_init): Check for self-assign after parsing
> class member initialization.
> * parser.c (cp_parser_assignment_expression): Check for self-assign
> after parsing an assignment.
> (cp_parser_init_declarator): Check for self-assign after parsing
> variable initialization.
>
> gcc/testsuite/ChangeLog
>
> * gcc.dg/plugin/selfassign.c (check_self_assign): Renamed from
> warn_self_assign.
> * gcc.dg/wself-assign-1.c: New test.
> * gcc.dg/wself-assign-2.c: New test.
> * gcc.dg/wself-assign-3.c: New test.
> * gcc.dg/uninit-D-O0.c: Add new warning.
> * gcc.dg/uninit-D.c: Add new warning.
> * gcc.dg/uninit-E-O0.c: Modify comment.
> * gcc.dg/uninit-E.c: Modify comment.
> * g++.dg/plugin/selfassign.c (check_self_assign): Renamed from
> warn_self_assign.
> * g++.dg/warn/Wself-assign-1.C: New test.
> * g++.dg/warn/Wself-assign-2.C: New test.
> * g++.dg/warn/Wself-assign-3.C: New test.
> * g++.dg/warn/Wself-assign-4.C: New test.
> * g++.dg/warn/Wself-assign-5.C: New test.
>
More information about the Gcc-patches
mailing list