Bug 27150 - [4.2 Regression] ICE with &parm_decl != 0 in build_binary_op
Summary: [4.2 Regression] ICE with &parm_decl != 0 in build_binary_op
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.2.0
: P1 normal
Target Milestone: 4.2.0
Assignee: Andrew Pinski
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2006-04-13 17:26 UTC by Andrew Pinski
Modified: 2006-06-05 03:08 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-04-19 20:25:26


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2006-04-13 17:26:00 UTC
Testcase:
int g(int f)
{
  return (&f)!=0;
}
-----
Just like PR 25861.
t.c:5: internal compiler error: tree check: expected tree that contains "decl with visibility" structure, have "parm_decl"  in build_binary_op, at c-typeck.c:7987
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Volker Reichelt 2006-04-19 20:25:26 UTC
Confirmed.
Comment 2 Andrew Pinski 2006-04-24 00:38:32 UTC
Here is the fix:
Index: c-typeck.c
===================================================================
--- c-typeck.c  (revision 113199)
+++ c-typeck.c  (working copy)
@@ -7978,7 +7978,8 @@ build_binary_op (enum tree_code code, tr
        {
          if (TREE_CODE (op0) == ADDR_EXPR
              && DECL_P (TREE_OPERAND (op0, 0)) 
-             && !DECL_WEAK (TREE_OPERAND (op0, 0)))
+             && (TREE_CODE (TREE_OPERAND(op0, 0)) == PARM_DECL
+                 || !DECL_WEAK (TREE_OPERAND (op0, 0))))
            warning (OPT_Walways_true, "the address of %qD will never be NULL",
                     TREE_OPERAND (op0, 0));
          result_type = type0;
@@ -7987,7 +7988,8 @@ build_binary_op (enum tree_code code, tr
        {
          if (TREE_CODE (op1) == ADDR_EXPR 
              && DECL_P (TREE_OPERAND (op1, 0))
-             && !DECL_WEAK (TREE_OPERAND (op1, 0)))
+             && (TREE_CODE (TREE_OPERAND(op1, 0)) == PARM_DECL
+                 || !DECL_WEAK (TREE_OPERAND (op1, 0))))
            warning (OPT_Walways_true, "the address of %qD will never be NULL",
                     TREE_OPERAND (op1, 0));
          result_type = type1;
Comment 3 Andrew Pinski 2006-05-08 07:54:14 UTC
Mine.
Comment 4 Roger Sayle 2006-06-05 02:28:28 UTC
Subject: Bug 27150

Author: sayle
Date: Mon Jun  5 02:28:20 2006
New Revision: 114380

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114380
Log:

	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.


Added:
    trunk/gcc/testsuite/gcc.dg/pr27150-1.c
    trunk/gcc/testsuite/gcc.dg/pr27382-1.c
    trunk/gcc/testsuite/gcc.dg/pr27382-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-common.c
    trunk/gcc/c-typeck.c

Comment 5 Roger Sayle 2006-06-05 02:31:53 UTC
Subject: Bug 27150

Author: sayle
Date: Mon Jun  5 02:31:41 2006
New Revision: 114381

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114381
Log:

	PR middle-end/27382
	PR c/27150
	* gcc.dg/pr27150-1.c: New testcase.
	* gcc.dg/pr27382-1.c: New testcase.
	* gcc.dg/pr27382-2.c: New testcase.


Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 6 Andrew Pinski 2006-06-05 03:08:34 UTC
Fixed.