From patchwork Mon Sep 5 08:59:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 113322 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 12C3FB6F70 for ; Mon, 5 Sep 2011 18:59:40 +1000 (EST) Received: (qmail 15318 invoked by alias); 5 Sep 2011 08:59:37 -0000 Received: (qmail 15310 invoked by uid 22791); 5 Sep 2011 08:59:35 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 05 Sep 2011 08:59:21 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 2049A8738D for ; Mon, 5 Sep 2011 10:59:20 +0200 (CEST) Date: Mon, 5 Sep 2011 10:59:20 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Use size_binop again in layout_type Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This reverts parts of 2011-04-11 Richard Guenther * stor-layout.c (layout_type): Compute all array index size operations in the original type. (initialize_sizetypes): Add comment. (set_sizetype): Do not set TREE_TYPE of a TREE_VEC. and retains the use of size_binop in layout_type while still preserving signedness. We then just need to make sure to always use a sizetype for domain types, the only case where we don't being in complete_array_type for a[]. Bootstrapped and tested on x86_64-unknown-linux-gnu, committed (c-common.c piece as obvious). Richard. 2011-09-05 Richard Guenther * stor-layout.c (layout_type): Use size_binop for array size calculations. c-family/ * c-common.c (complete_array_type): Use ssize_int (-1) instead of integer_minus_one_node for empty array upper bounds. Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c (revision 178523) +++ gcc/stor-layout.c (working copy) @@ -1959,16 +1959,15 @@ layout_type (tree type) if (integer_zerop (element_size)) length = size_zero_node; - /* The computation should happen in the original type so - that (possible) negative values are handled appropriately. */ + /* The computation should happen in the original signedness so + that (possible) negative values are handled appropriately + when determining overflow. */ else length = fold_convert (sizetype, - fold_build2 (PLUS_EXPR, TREE_TYPE (lb), - build_int_cst (TREE_TYPE (lb), 1), - fold_build2 (MINUS_EXPR, - TREE_TYPE (lb), - ub, lb))); + size_binop (PLUS_EXPR, + build_int_cst (TREE_TYPE (lb), 1), + size_binop (MINUS_EXPR, ub, lb))); TYPE_SIZE (type) = size_binop (MULT_EXPR, element_size, fold_convert (bitsizetype, Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c (revision 178523) +++ gcc/c-family/c-common.c (working copy) @@ -8844,7 +8844,7 @@ complete_array_type (tree *ptype, tree i { if (pedantic) failure = 3; - maxindex = integer_minus_one_node; + maxindex = ssize_int (-1); } else {