From f6f083604b2a742a0b15e01384fa1337ee231400 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Thu, 26 Jan 2006 14:59:26 +0000 Subject: [PATCH] re PR c/25861 (tree check fail at c-common.c:2430) 2006-01-26 Andrew Pinski PR C/25861 * c-common.c (c_common_truthvalue_conversion) : Use a new variable, inner. PARM_DECLs are always non-weak. 2006-01-26 Andrew Pinski PR C/25861 * gcc.c-torture/compile/pr25861.c: New test. From-SVN: r110256 --- gcc/ChangeLog | 6 ++++++ gcc/c-common.c | 15 ++++++++------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr25861.c | 4 ++++ 4 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr25861.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 71144c3..f925b00 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-01-26 Andrew Pinski + + PR C/25861 + * c-common.c (c_common_truthvalue_conversion) : + Use a new variable, inner. PARM_DECLs are always non-weak. + 2006-01-26 Shantonu Sen * tree.h (OMP_CLAUSE_SUBCODE_CHECK): Add definition for diff --git a/gcc/c-common.c b/gcc/c-common.c index 60035ea..fe99dfb 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2456,25 +2456,26 @@ c_common_truthvalue_conversion (tree expr) case ADDR_EXPR: { - if (DECL_P (TREE_OPERAND (expr, 0)) - && !DECL_WEAK (TREE_OPERAND (expr, 0))) + tree inner = TREE_OPERAND (expr, 0); + if (DECL_P (inner) + && (TREE_CODE (inner) == PARM_DECL || !DECL_WEAK (inner))) { /* Common Ada/Pascal programmer's mistake. We always warn about this since it is so bad. */ warning (OPT_Walways_true, "the address of %qD, will always evaluate as %", - TREE_OPERAND (expr, 0)); + inner); return truthvalue_true_node; } /* If we are taking the address of an external decl, it might be zero if it is weak, so we cannot optimize. */ - if (DECL_P (TREE_OPERAND (expr, 0)) - && DECL_EXTERNAL (TREE_OPERAND (expr, 0))) + if (DECL_P (inner) + && DECL_EXTERNAL (inner)) break; - if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 0))) + if (TREE_SIDE_EFFECTS (inner)) return build2 (COMPOUND_EXPR, truthvalue_type_node, - TREE_OPERAND (expr, 0), truthvalue_true_node); + inner, truthvalue_true_node); else return truthvalue_true_node; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dde3de8..0042b36 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-01-26 Andrew Pinski + + PR C/25861 + * gcc.c-torture/compile/pr25861.c: New test. + 2006-01-26 Paul Brook * gcc.dg/compat/struct-layout-1.exp: Pass -e to generator program diff --git a/gcc/testsuite/gcc.c-torture/compile/pr25861.c b/gcc/testsuite/gcc.c-torture/compile/pr25861.c new file mode 100644 index 0000000..cdd8efb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr25861.c @@ -0,0 +1,4 @@ +int f(void *a) +{ + return !(&a); +} -- 2.7.4