Commit ffbf5f7f by Roger Sayle Committed by Roger Sayle

re PR middle-end/27382 (ICE in c_common_truthvalue_conversion with label address)


	PR middle-end/27382
	* c-common.c (c_common_truthvalue_conversion): Explicitly check
	for LABEL_DECL before calling DECL_WEAK.

	PR c/27150
	* c-typeck.c (build_binary_op): Likewise, explicitly check for
	LABEL_DECL and PARM_DECL.

	* gcc.dg/pr27150-1.c: New testcase.
	* gcc.dg/pr27382-1.c: New testcase.
	* gcc.dg/pr27382-2.c: New testcase.


Co-Authored-By: Andrew Pinski <pinskia@physics.uc.edu>

From-SVN: r114380
parent 5c076987
2006-06-04 Roger Sayle <roger@eyesopen.com>
Andrew Pinski <pinskia@physics.uc.edu>
PR middle-end/27382
* c-common.c (c_common_truthvalue_conversion): Explicitly check
for LABEL_DECL before calling DECL_WEAK.
PR c/27150
* c-typeck.c (build_binary_op): Likewise, explicitly check for
LABEL_DECL and PARM_DECL.
2006-06-05 Joseph S. Myers <joseph@codesourcery.com> 2006-06-05 Joseph S. Myers <joseph@codesourcery.com>
PR c/25161 PR c/25161
......
...@@ -2501,7 +2501,9 @@ c_common_truthvalue_conversion (tree expr) ...@@ -2501,7 +2501,9 @@ c_common_truthvalue_conversion (tree expr)
{ {
tree inner = TREE_OPERAND (expr, 0); tree inner = TREE_OPERAND (expr, 0);
if (DECL_P (inner) if (DECL_P (inner)
&& (TREE_CODE (inner) == PARM_DECL || !DECL_WEAK (inner))) && (TREE_CODE (inner) == PARM_DECL
|| TREE_CODE (inner) == LABEL_DECL
|| !DECL_WEAK (inner)))
{ {
/* Common Ada/Pascal programmer's mistake. We always warn /* Common Ada/Pascal programmer's mistake. We always warn
about this since it is so bad. */ about this since it is so bad. */
......
...@@ -7996,7 +7996,9 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, ...@@ -7996,7 +7996,9 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
{ {
if (TREE_CODE (op0) == ADDR_EXPR if (TREE_CODE (op0) == ADDR_EXPR
&& DECL_P (TREE_OPERAND (op0, 0)) && DECL_P (TREE_OPERAND (op0, 0))
&& !DECL_WEAK (TREE_OPERAND (op0, 0))) && (TREE_CODE (TREE_OPERAND (op0, 0)) == PARM_DECL
|| TREE_CODE (TREE_OPERAND (op0, 0)) == LABEL_DECL
|| !DECL_WEAK (TREE_OPERAND (op0, 0))))
warning (OPT_Walways_true, "the address of %qD will never be NULL", warning (OPT_Walways_true, "the address of %qD will never be NULL",
TREE_OPERAND (op0, 0)); TREE_OPERAND (op0, 0));
result_type = type0; result_type = type0;
...@@ -8005,7 +8007,9 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, ...@@ -8005,7 +8007,9 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
{ {
if (TREE_CODE (op1) == ADDR_EXPR if (TREE_CODE (op1) == ADDR_EXPR
&& DECL_P (TREE_OPERAND (op1, 0)) && DECL_P (TREE_OPERAND (op1, 0))
&& !DECL_WEAK (TREE_OPERAND (op1, 0))) && (TREE_CODE (TREE_OPERAND (op1, 0)) == PARM_DECL
|| TREE_CODE (TREE_OPERAND (op1, 0)) == LABEL_DECL
|| !DECL_WEAK (TREE_OPERAND (op1, 0))))
warning (OPT_Walways_true, "the address of %qD will never be NULL", warning (OPT_Walways_true, "the address of %qD will never be NULL",
TREE_OPERAND (op1, 0)); TREE_OPERAND (op1, 0));
result_type = type1; result_type = type1;
......
/* { dg-do compile } */
/* { dg-options "-O2" } */
int g(int f)
{
return (&f)!=0;
}
/* { dg-do compile } */
/* { dg-options "-O2" } */
void foo()
{
L:
!&&L;
}
/* { dg-do compile } */
/* { dg-options "-O2" } */
void foo()
{
L:
&&L != 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