From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18469 invoked by alias); 6 May 2008 14:23:53 -0000 Received: (qmail 17745 invoked by uid 48); 6 May 2008 14:23:07 -0000 Date: Tue, 06 May 2008 14:23:00 -0000 Message-ID: <20080506142307.17744.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/36013] [4.1/4.3/4.4 Regression] Wrong code involving restricted pointers to non-restricted pointers In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "ian at airs dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-05/txt/msg00434.txt.bz2 ------- Comment #5 from ian at airs dot com 2008-05-06 14:23 ------- I introduced DECL_BASED_ON_RESTRICT_P because the conversion to SSA discarded almost all information about restrict qualifiers. The compiler was tracking restrict qualifiers on the original variable, but not on the GIMPLE variables. The main use of restrict qualifiers at the RTL level is in the scheduler, and I didn't realize that it would be possible to write a machine-independent test case. DECL_BASED_ON_RESTRICT_P is meant to indicate that the temporary has the same restrict qualifiers as the DECL_GET_RESTRICT_BASE. It's not meant to be a general implementation of "based on" as defined by the standard. It's only meant to say "this GIMPLE temporary has the same restrict qualifiers as this user variable." This patch fixes the problem, although I haven't tested it. Index: gimplify.c =================================================================== --- gimplify.c (revision 134283) +++ gimplify.c (working copy) @@ -391,6 +391,13 @@ find_single_pointer_decl_1 (tree *tp, in { tree *pdecl = (tree *) data; + /* We are only looking for pointers at the same level as the + original tree; we must not look through any indirections. + Returning anything other than NULL_TREE will cause the caller to + not find a base. */ + if (REFERENCE_CLASS_P (*tp)) + return *tp; + if (DECL_P (*tp) && POINTER_TYPE_P (TREE_TYPE (*tp))) { if (*pdecl) @@ -406,8 +413,9 @@ find_single_pointer_decl_1 (tree *tp, in return NULL_TREE; } -/* Find the single DECL of pointer type in the tree T and return it. - If there are zero or more than one such DECLs, return NULL. */ +/* Find the single DECL of pointer type in the tree T, used directly + rather than via an indirection, and return it. If there are zero + or more than one such DECLs, return NULL. */ static tree find_single_pointer_decl (tree t) @@ -418,7 +426,8 @@ find_single_pointer_decl (tree t) { /* find_single_pointer_decl_1 returns a nonzero value, causing walk_tree to return a nonzero value, to indicate that it - found more than one pointer DECL. */ + found more than one pointer DECL or that it found an + indirection. */ return NULL_TREE; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36013