Commit 638fc14f by Marek Polacek Committed by Marek Polacek

re PR c/71926 (wrong location for -Wparentheses warning)

	PR c/71926
	* c-common.c (c_common_truthvalue_conversion): Use LOCATION for the
	parentheses warning.

	* semantics.c (maybe_convert_cond): Use the location of COND for the
	parentheses warning.

	* g++.dg/warn/Wparentheses-30.C: New test.
	* gcc.dg/Wparentheses-14.c: New test.

From-SVN: r238886
parent e00dceaf
2016-07-29 Marek Polacek <polacek@redhat.com>
PR c/71926
* c-common.c (c_common_truthvalue_conversion): Use LOCATION for the
parentheses warning.
PR c/71574
* c-common.c (handle_alloc_align_attribute): Also check FUNCTION_DECL.
......
......@@ -4591,8 +4591,9 @@ c_common_truthvalue_conversion (location_t location, tree expr)
if (!TREE_NO_WARNING (expr)
&& warn_parentheses)
{
warning (OPT_Wparentheses,
"suggest parentheses around assignment used as truth value");
warning_at (location, OPT_Wparentheses,
"suggest parentheses around assignment used as "
"truth value");
TREE_NO_WARNING (expr) = 1;
}
break;
......
2016-07-29 Marek Polacek <polacek@redhat.com>
PR c/71926
* semantics.c (maybe_convert_cond): Use the location of COND for the
parentheses warning.
2016-07-29 Jason Merrill <jason@redhat.com>
* decl.c (build_enumerator): Tweak diagnostic.
......
......@@ -656,7 +656,7 @@ maybe_convert_cond (tree cond)
&& !TREE_NO_WARNING (cond)
&& warn_parentheses)
{
warning (OPT_Wparentheses,
warning_at (EXPR_LOC_OR_LOC (cond, input_location), OPT_Wparentheses,
"suggest parentheses around assignment used as truth value");
TREE_NO_WARNING (cond) = 1;
}
......
......@@ -11,6 +11,10 @@
PR c/71573
* gcc.dg/noncompile/pr71573.c: New test.
PR c/71926
* g++.dg/warn/Wparentheses-30.C: New test.
* gcc.dg/Wparentheses-14.c: New test.
2016-07-29 Uros Bizjak <ubizjak@gmail.com>
* gcc.dg/pr59833.c: Use dg-add-options ieee.
......
/* PR c/71926 */
/* { dg-options "-Wparentheses" } */
int
f (void)
{
int a = 1, b = 2, c = 3, d = 4;
if (a = 2 || (b != 3 && c != 4 && d != 5)) /* { dg-warning "9:suggest parentheses" } */
return 1;
return 0;
}
/* PR c/71926 */
/* { dg-options "-Wparentheses" } */
int
f (void)
{
int a = 1, b = 2, c = 3, d = 4;
if (a = 2 || (b != 3 && c != 4 && d != 5)) /* { dg-warning "7:suggest parentheses" } */
return 1;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment