Commit de55efd5 by Marek Polacek Committed by Marek Polacek

re PR c/48778 (gcc 4.6 -Waddress adds unhelpful new warning case when using from a macro)

	PR c/48778
	* c-typeck.c (build_binary_op): Don't issue -Waddress warnings
	for macro expansions.

	* gcc.dg/Waddress-2.c: New test.

From-SVN: r235878
parent ec6be462
2016-05-04 Marek Polacek <polacek@redhat.com>
PR c/48778
* c-typeck.c (build_binary_op): Don't issue -Waddress warnings
for macro expansions.
2016-05-03 Marek Polacek <polacek@redhat.com>
PR c/70859
......
......@@ -11067,7 +11067,8 @@ build_binary_op (location_t location, enum tree_code code,
else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1))
{
if (TREE_CODE (op0) == ADDR_EXPR
&& decl_with_nonnull_addr_p (TREE_OPERAND (op0, 0)))
&& decl_with_nonnull_addr_p (TREE_OPERAND (op0, 0))
&& !from_macro_expansion_at (location))
{
if (code == EQ_EXPR)
warning_at (location,
......@@ -11087,7 +11088,8 @@ build_binary_op (location_t location, enum tree_code code,
else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
{
if (TREE_CODE (op1) == ADDR_EXPR
&& decl_with_nonnull_addr_p (TREE_OPERAND (op1, 0)))
&& decl_with_nonnull_addr_p (TREE_OPERAND (op1, 0))
&& !from_macro_expansion_at (location))
{
if (code == EQ_EXPR)
warning_at (location,
......
2016-05-04 Marek Polacek <polacek@redhat.com>
PR c/48778
* gcc.dg/Waddress-2.c: New test.
2016-05-04 Alan Modra <amodra@gmail.com>
* gcc.target/powerpc/pr70866.c: New.
......
/* PR c/48778 */
/* { dg-do compile } */
/* { dg-options "-Waddress" } */
#define NULL ((void *) 0)
#define M1(b) ((b) != NULL ? 0 : (b))
#define M2(b) ((b) == NULL ? 0 : (b))
#define M3(b) (NULL != (b) ? 0 : (b))
#define M4(b) (NULL == (b) ? 0 : (b))
int
func (int b)
{
if (M1 (&b) > 0)
return 1;
if (M2 (&b) > 0)
return 2;
if (M3 (&b) > 0)
return 3;
if (M4 (&b) > 0)
return 4;
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