From patchwork Thu May 10 16:44:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 158346 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 A70B3B6FA3 for ; Fri, 11 May 2012 02:46:35 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1337273197; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:Subject:From:To:Cc: Content-Type:Date:Message-ID:Mime-Version: Content-Transfer-Encoding:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=/a6Y49gp7ukSXPzkdk9eNjSI+Bw=; b=HjCsI/rcJkDyv+7 L7NaG8Ftr7qDDDw1PcBhcQ2CzaQgn1RNH4pajvz6AxalTF5IHyKK9qXeFF9qVEDT UdgEdDuDcs4pt8YolMm1EmpqKZ/gFHITEnoGSLYTGuloAKqOPcqRt4zt3+HrmIb8 4S4GGG1qoucpbLP+5NWq05/pF2ek= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Received:Received:Subject:From:To:Cc:Content-Type:Date:Message-ID:Mime-Version:Content-Transfer-Encoding:X-Content-Scanned:x-cbid:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=q8jMwa76mg545s0TzJyDDMCsxIiCd6jJxmPS/+0JkViTms6QB8VjaDAZFz/sOQ Iibqfk45ZVYvgRYUxa5nTvxafjePO+YgOFLhOwGHrD7mSP9VBT4gPiaVkNOqdCHs zWErKXLvkyTAv1g9uOjn91YZhEiDs0v1NFoSIXFCTIV8A=; Received: (qmail 25426 invoked by alias); 10 May 2012 16:46:31 -0000 Received: (qmail 25418 invoked by uid 22791); 10 May 2012 16:46:29 -0000 X-SWARE-Spam-Status: No, hits=-3.9 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, MAY_BE_FORGED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e32.co.us.ibm.com (HELO e32.co.us.ibm.com) (32.97.110.150) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 May 2012 16:46:16 +0000 Received: from /spool/local by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 May 2012 10:46:14 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 10 May 2012 10:45:01 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 7532D19D805E for ; Thu, 10 May 2012 10:44:49 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q4AGiUQV189638 for ; Thu, 10 May 2012 10:44:30 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q4AGiUxw027507 for ; Thu, 10 May 2012 10:44:30 -0600 Received: from [9.10.86.87] (vitruvian.rchland.ibm.com [9.10.86.87] (may be forged)) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q4AGiSuX027403; Thu, 10 May 2012 10:44:28 -0600 Subject: [PATCH, 4.7] Backport fix to [un]signed_type_for From: "William J. Schmidt" To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de, bergner@vnet.ibm.com Date: Thu, 10 May 2012 11:44:27 -0500 Message-ID: <1336668267.4707.6.camel@oc2474580526.ibm.com> Mime-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12051016-3270-0000-0000-0000063B57C6 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 Backporting this patch to 4.7 fixes a problem building Fedora 17. Bootstrapped and regression tested on powerpc64-unknown-linux-gnu. Is the backport OK? Thanks, Bill 2012-05-10 Bill Schmidt Backport from trunk: 2012-03-12 Richard Guenther * tree.c (signed_or_unsigned_type_for): Use build_nonstandard_integer_type. (signed_type_for): Adjust documentation. (unsigned_type_for): Likewise. * tree-pretty-print.c (dump_generic_node): Use standard names for non-standard integer types if available. Index: gcc/tree-pretty-print.c =================================================================== --- gcc/tree-pretty-print.c (revision 187368) +++ gcc/tree-pretty-print.c (working copy) @@ -723,11 +723,41 @@ dump_generic_node (pretty_printer *buffer, tree no } else if (TREE_CODE (node) == INTEGER_TYPE) { - pp_string (buffer, (TYPE_UNSIGNED (node) - ? ""); + if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE) + pp_string (buffer, (TYPE_UNSIGNED (node) + ? "unsigned char" + : "signed char")); + else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE) + pp_string (buffer, (TYPE_UNSIGNED (node) + ? "unsigned short" + : "signed short")); + else if (TYPE_PRECISION (node) == INT_TYPE_SIZE) + pp_string (buffer, (TYPE_UNSIGNED (node) + ? "unsigned int" + : "signed int")); + else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE) + pp_string (buffer, (TYPE_UNSIGNED (node) + ? "unsigned long" + : "signed long")); + else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE) + pp_string (buffer, (TYPE_UNSIGNED (node) + ? "unsigned long long" + : "signed long long")); + else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE + && exact_log2 (TYPE_PRECISION (node))) + { + pp_string (buffer, (TYPE_UNSIGNED (node) ? "uint" : "int")); + pp_decimal_int (buffer, TYPE_PRECISION (node)); + pp_string (buffer, "_t"); + } + else + { + pp_string (buffer, (TYPE_UNSIGNED (node) + ? ""); + } } else if (TREE_CODE (node) == COMPLEX_TYPE) { Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 187368) +++ gcc/tree.c (working copy) @@ -10162,32 +10162,26 @@ widest_int_cst_value (const_tree x) return val; } -/* If TYPE is an integral type, return an equivalent type which is - unsigned iff UNSIGNEDP is true. If TYPE is not an integral type, - return TYPE itself. */ +/* If TYPE is an integral or pointer type, return an integer type with + the same precision which is unsigned iff UNSIGNEDP is true, or itself + if TYPE is already an integer type of signedness UNSIGNEDP. */ tree signed_or_unsigned_type_for (int unsignedp, tree type) { - tree t = type; - if (POINTER_TYPE_P (type)) - { - /* If the pointer points to the normal address space, use the - size_type_node. Otherwise use an appropriate size for the pointer - based on the named address space it points to. */ - if (!TYPE_ADDR_SPACE (TREE_TYPE (t))) - t = size_type_node; - else - return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp); - } + if (TREE_CODE (type) == INTEGER_TYPE && TYPE_UNSIGNED (type) == unsignedp) + return type; - if (!INTEGRAL_TYPE_P (t) || TYPE_UNSIGNED (t) == unsignedp) - return t; + if (!INTEGRAL_TYPE_P (type) + && !POINTER_TYPE_P (type)) + return NULL_TREE; - return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp); + return build_nonstandard_integer_type (TYPE_PRECISION (type), unsignedp); } -/* Returns unsigned variant of TYPE. */ +/* If TYPE is an integral or pointer type, return an integer type with + the same precision which is unsigned, or itself if TYPE is already an + unsigned integer type. */ tree unsigned_type_for (tree type) @@ -10195,7 +10189,9 @@ unsigned_type_for (tree type) return signed_or_unsigned_type_for (1, type); } -/* Returns signed variant of TYPE. */ +/* If TYPE is an integral or pointer type, return an integer type with + the same precision which is signed, or itself if TYPE is already a + signed integer type. */ tree signed_type_for (tree type)