summaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-26 14:59:26 +0000
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-26 14:59:26 +0000
commitee7d4d6a9eb3853a384963475e9540d8087ca5cd (patch)
tree3ddf13d99d2fe455060fa7801f66ca377299cd4c /gcc/c-common.c
parent07d32e0113094fb014b19f975597326eb9505233 (diff)
downloadgcc-ee7d4d6a9eb3853a384963475e9540d8087ca5cd.tar.gz
2006-01-26 Andrew Pinski <pinskia@physics.uc.edu>
PR C/25861 * c-common.c (c_common_truthvalue_conversion) <case ADDR_EXPR>: Use a new variable, inner. PARM_DECLs are always non-weak. 2006-01-26 Andrew Pinski <pinskia@physics.uc.edu> PR C/25861 * gcc.c-torture/compile/pr25861.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110256 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 60035ea601b..fe99dfb24af 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 %<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;
}