From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8159 invoked by alias); 21 Nov 2007 20:46:58 -0000 Received: (qmail 8147 invoked by uid 22791); 21 Nov 2007 20:46:57 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 21 Nov 2007 20:46:39 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.1) with ESMTP id lALKkbhb012562; Wed, 21 Nov 2007 15:46:37 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lALKkb38016857; Wed, 21 Nov 2007 15:46:37 -0500 Received: from pantani.quesejoda.com (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lALKkaba032723; Wed, 21 Nov 2007 15:46:36 -0500 Received: by pantani.quesejoda.com (Postfix, from userid 500) id 3A74611A0341; Wed, 21 Nov 2007 16:46:36 -0400 (AST) Date: Wed, 21 Nov 2007 22:03:00 -0000 From: Aldy Hernandez To: dnovillo@google.com, gcc-patches@gcc.gnu.org Subject: [tuples] dereference POINTER_PLUS_EXPR check Message-ID: <20071121204635.GA7204@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-11/txt/msg01127.txt.bz2 Hi Diego. Many fortran testcases are failing in verify_types_in_gimple_assign() because, in a GIMPLE_ASSIGN, a POINTER_PLUS_EXPR can be embeddeded in an assignment. However, when verifying type validity, we no longer have the type of the POINTER_PLUS_EXPR. In the absence of this type, we must look at the pointed-to type to determine type compatability. This patch drills down to the dereferenced type. With this patch, we have no ICEs that are not already present on mainline while checking fortran. Is this OK for the tuples branch? Aldy * tree-cfg.c (verify_types_in_gimple_assign): Use the dereferenced type when checking the validity of a POINTER_PLUS_EXPR. Index: tree-cfg.c =================================================================== --- tree-cfg.c (revision 130313) +++ tree-cfg.c (working copy) @@ -3558,16 +3558,37 @@ verify_types_in_gimple_assign (gimple st error ("invalid operands in pointer plus expression"); return true; } - if (!POINTER_TYPE_P (rhs1_type) - || !useless_type_conversion_p (lhs_type, rhs1_type) + + if (!POINTER_TYPE_P (lhs_type) + || !POINTER_TYPE_P (rhs1_type)) + { + error ("type mismatch in pointer plus expression"); + return true; + } + + /* Drill down to get to the pointed-to type. */ + { + tree lhs_type_orig = lhs_type; + tree rhs1_type_orig = rhs1_type; + + while (POINTER_TYPE_P (rhs1_type) + || TREE_CODE (rhs1_type) == ARRAY_TYPE) + rhs1_type = TREE_TYPE (rhs1_type); + + while (POINTER_TYPE_P (lhs_type) + || TREE_CODE (lhs_type) == ARRAY_TYPE) + lhs_type = TREE_TYPE (lhs_type); + + if (!useless_type_conversion_p (lhs_type, rhs1_type) || !useless_type_conversion_p (sizetype, rhs2_type)) { error ("type mismatch in pointer plus expression"); - debug_generic_stmt (lhs_type); - debug_generic_stmt (rhs1_type); + debug_generic_stmt (lhs_type_orig); + debug_generic_stmt (rhs1_type_orig); debug_generic_stmt (rhs2_type); return true; } + } return false; }