This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] [C/C++] Add a new warning flag -Wself-assign


On Wed, Jul 21, 2010 at 05:45:16PM -0700, Le-Chun Wu wrote:
> 
> Attached is the revised patch that incorporates Manuel's and Jason's
> comments. Bootstrapped (with additional patches that address the
> self-assign code in GCC source) and tested on x86_64-gnu-linux. OK for
> trunk? (If it's OK, I will make sure the patches that fix the
> self-assign warnings in GCC source get submitted before this one.)
> Thanks.
> 

Le-chun,
    Would it make sense to extend the -Wself-assign flag to
other languages in gcc (like fortran for example)?
                    Jack

> Le-chun
> 
> 
> gcc/ChangeLog:
> 
> 2010-07-21  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.
> 
> gcc/c-family/ChangeLog
> 
> 2010-07-21  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-07-21  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
> 
> 2010-07-21  Le-Chun Wu  <lcwu@google.com>
> 
>         * 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.
>         * g++.dg/warn/Wself-assign-6.C: New test.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]