gcc/gcc/c-family
Marek Polacek 2ebd93e1d7 re PR c/64279 (Warning missing for "(cond) ? A : A" / if(cond) expr1; else expr1; // same expression in if and else branch)
PR c/64279
	* c-common.h (do_warn_duplicated_branches_r): Declare.
	* c-gimplify.c (c_genericize): Walk the function tree calling
	do_warn_duplicated_branches_r.
	* c-warn.c (expr_from_macro_expansion_r): New.
	(do_warn_duplicated_branches): New.
	(do_warn_duplicated_branches_r): New.
	* c.opt (Wduplicated-branches): New option.

	* c-typeck.c (build_conditional_expr): Warn about duplicated branches.

	* call.c (build_conditional_expr_1): Warn about duplicated branches.
	* semantics.c (finish_expr_stmt): Build statement using the proper
	location.

	* doc/invoke.texi: Document -Wduplicated-branches.
	* fold-const.c (operand_equal_p): Handle MODIFY_EXPR, INIT_EXPR,
	COMPOUND_EXPR, PREDECREMENT_EXPR, PREINCREMENT_EXPR,
	POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, CLEANUP_POINT_EXPR, EXPR_STMT,
	STATEMENT_LIST, and RETURN_EXPR.  For non-pure non-const functions
	return 0 only when not OEP_LEXICOGRAPHIC.
	(fold_build_cleanup_point_expr): Use the expression
	location when building CLEANUP_POINT_EXPR.
	* tree-core.h (enum operand_equal_flag): Add OEP_LEXICOGRAPHIC.
	* tree.c (add_expr): Handle error_mark_node.

	* c-c++-common/Wduplicated-branches-1.c: New test.
	* c-c++-common/Wduplicated-branches-10.c: New test.
	* c-c++-common/Wduplicated-branches-11.c: New test.
	* c-c++-common/Wduplicated-branches-12.c: New test.
	* c-c++-common/Wduplicated-branches-2.c: New test.
	* c-c++-common/Wduplicated-branches-3.c: New test.
	* c-c++-common/Wduplicated-branches-4.c: New test.
	* c-c++-common/Wduplicated-branches-5.c: New test.
	* c-c++-common/Wduplicated-branches-6.c: New test.
	* c-c++-common/Wduplicated-branches-7.c: New test.
	* c-c++-common/Wduplicated-branches-8.c: New test.
	* c-c++-common/Wduplicated-branches-9.c: New test.
	* c-c++-common/Wimplicit-fallthrough-7.c: Coalesce dg-warning.
	* g++.dg/cpp0x/lambda/lambda-switch.C: Move dg-warning.
	* g++.dg/ext/builtin-object-size3.C: Likewise.
	* g++.dg/gomp/loop-1.C: Likewise.
	* g++.dg/warn/Wduplicated-branches1.C: New test.
	* g++.dg/warn/Wduplicated-branches2.C: New test.

From-SVN: r244705
2017-01-20 12:02:50 +00:00
..
ChangeLog re PR c/64279 (Warning missing for "(cond) ? A : A" / if(cond) expr1; else expr1; // same expression in if and else branch) 2017-01-20 12:02:50 +00:00
ChangeLog.gimple-classes Merger of git branch "gimple-classes-v2-option-3" 2014-11-19 17:00:54 +00:00
array-notation-common.c re PR c/79116 (ICE on cilkplus array notation with a _Cilk_for) 2017-01-17 15:27:18 +00:00
c-ada-spec.c Update copyright years. 2017-01-01 13:07:43 +01:00
c-ada-spec.h Update copyright years. 2017-01-01 13:07:43 +01:00
c-attribs.c Update copyright years. 2017-01-01 13:07:43 +01:00
c-cilkplus.c Update copyright years. 2017-01-01 13:07:43 +01:00
c-common.c revert: re PR c++/71737 (ICE following 2x pack expansion in non-pack with template alias) 2017-01-16 15:43:06 +00:00
c-common.def Update copyright years. 2017-01-01 13:07:43 +01:00
c-common.h re PR c/64279 (Warning missing for "(cond) ? A : A" / if(cond) expr1; else expr1; // same expression in if and else branch) 2017-01-20 12:02:50 +00:00
c-cppbuiltin.c * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_variadic_using. 2017-01-10 14:04:28 -05:00
c-dump.c Update copyright years. 2017-01-01 13:07:43 +01:00
c-format.c Update copyright years. 2017-01-01 13:07:43 +01:00
c-format.h Update copyright years. 2017-01-01 13:07:43 +01:00
c-gimplify.c re PR c/64279 (Warning missing for "(cond) ? A : A" / if(cond) expr1; else expr1; // same expression in if and else branch) 2017-01-20 12:02:50 +00:00
c-indentation.c Fix wording of -Wmisleading-indentation (PR c++/71497) 2017-01-17 16:33:44 +00:00
c-indentation.h Update copyright years. 2017-01-01 13:07:43 +01:00
c-lex.c Update copyright years. 2017-01-01 13:07:43 +01:00
c-objc.h Update copyright years. 2017-01-01 13:07:43 +01:00
c-omp.c Update copyright years. 2017-01-01 13:07:43 +01:00
c-opts.c Error for '-' as filename of a precompiled header (PR pch/78970) 2017-01-05 14:17:07 +00:00
c-pch.c Update copyright years. 2017-01-01 13:07:43 +01:00
c-ppoutput.c Update copyright years. 2017-01-01 13:07:43 +01:00
c-pragma.c Update copyright years. 2017-01-01 13:07:43 +01:00
c-pragma.h Update copyright years. 2017-01-01 13:07:43 +01:00
c-pretty-print.c [bootstrap-O1] change value type to avoid sprintf buffer size warning 2017-01-06 03:34:25 +00:00
c-pretty-print.h Update copyright years. 2017-01-01 13:07:43 +01:00
c-semantics.c Update copyright years. 2017-01-01 13:07:43 +01:00
c-target-def.h Update copyright years. 2017-01-01 13:07:43 +01:00
c-target.def Update copyright years. 2017-01-01 13:07:43 +01:00
c-target.h Update copyright years. 2017-01-01 13:07:43 +01:00
c-ubsan.c Update copyright years. 2017-01-01 13:07:43 +01:00
c-ubsan.h Update copyright years. 2017-01-01 13:07:43 +01:00
c-warn.c re PR c/64279 (Warning missing for "(cond) ? A : A" / if(cond) expr1; else expr1; // same expression in if and else branch) 2017-01-20 12:02:50 +00:00
c.opt re PR c/64279 (Warning missing for "(cond) ? A : A" / if(cond) expr1; else expr1; // same expression in if and else branch) 2017-01-20 12:02:50 +00:00
cilk.c Update copyright years. 2017-01-01 13:07:43 +01:00
cppspec.c Update copyright years. 2017-01-01 13:07:43 +01:00
stub-objc.c Update copyright years. 2017-01-01 13:07:43 +01:00