This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/25861] [4.2 Regression] tree check fail at c-common.c:2430
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Jan 2006 16:16:21 -0000
- Subject: [Bug c/25861] [4.2 Regression] tree check fail at c-common.c:2430
- References: <bug-25861-9596@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #9 from pinskia at gcc dot gnu dot org 2006-01-24 16:16 -------
The full patch (with some cleanup) is:
Index: c-common.c
===================================================================
--- c-common.c (revision 110173)
+++ c-common.c (working copy)
@@ -2456,25 +2456,26 @@ c_common_truthvalue_conversion (tree exp
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 %<true%>",
- 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;
}
I am testing this right now.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25861