From patchwork Wed Dec 7 11:27:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 87028 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp263308qgi; Wed, 7 Dec 2016 03:31:05 -0800 (PST) X-Received: by 10.99.37.195 with SMTP id l186mr119263446pgl.91.1481110265744; Wed, 07 Dec 2016 03:31:05 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l26si23715136pli.44.2016.12.07.03.31.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Dec 2016 03:31:05 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-443669-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-443669-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-443669-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=dP74BjIrVUVBI3By PzXnyTWIu4WSyhYqySZ7xl8lFylMjZQ0XU2+d388G61ZHe+m3XjzLuOBWyL5XVcJ JrRmggC2dW2eDM0WmgX+uo0oBM1/totYLEog9GLWCAW6FaRZaLLT5c/EKfevDfgo aPajNmdC0QYWqXmfYNndeSg1MQk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=y5QexVmhRv1Wjrd5/bUyIu Q6c1Y=; b=lFxH8XAn01IQ7xKSwZ1EE4lc2jqgvALypfigHq7a5JNE3Cy3Xxrxy2 Y+fZsqjwX/Rao383jrbxmVNWJbYo4LOHnzCgecRg3vz5RdH9MrUHq1XS/sb2vwu1 qJ2IKn7A4bh7nAzk3CVZr6oIZcMAhAX1dHRNOiJ3oi1u18xICd0cs= Received: (qmail 63848 invoked by alias); 7 Dec 2016 11:28:08 -0000 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 Received: (qmail 63525 invoked by uid 89); 7 Dec 2016 11:28:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 spammy=our X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Dec 2016 11:27:45 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id AE8D7814E1 for ; Wed, 7 Dec 2016 12:27:42 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aiMUjrsfmqst for ; Wed, 7 Dec 2016 12:27:42 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 869AF812DF for ; Wed, 7 Dec 2016 12:27:42 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix debug info for character subtypes Date: Wed, 07 Dec 2016 12:27:42 +0100 Message-ID: <6405764.s7hPEK9ofN@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-48-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 This fixes a regression present on the mainline and 6 branch for the debug info of character subtypes, whose bounds are output as signed instead of unsigned values as per the language. Tested on x86_64-suse-linux, applied on the mainline and 6 branch. 2016-12-07 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : Also call finish_character_type on Character subtypes. * gcc-interface/utils.c (finish_character_type): Deal with subtypes. -- Eric Botcazou Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 243333) +++ gcc-interface/decl.c (working copy) @@ -1859,8 +1859,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entit TYPE_BIASED_REPRESENTATION_P (gnu_type) = Has_Biased_Representation (gnat_entity); - /* Set TYPE_STRING_FLAG for Character and Wide_Character subtypes. */ - TYPE_STRING_FLAG (gnu_type) = TYPE_STRING_FLAG (TREE_TYPE (gnu_type)); + /* Do the same processing for Character subtypes as for types. */ + if (TYPE_STRING_FLAG (TREE_TYPE (gnu_type))) + { + TYPE_NAME (gnu_type) = gnu_entity_name; + TYPE_STRING_FLAG (gnu_type) = 1; + TYPE_ARTIFICIAL (gnu_type) = artificial_p; + finish_character_type (gnu_type); + } /* Inherit our alias set from what we're a subtype of. Subtypes are not different types and a pointer can designate any instance Index: gcc-interface/utils.c =================================================================== --- gcc-interface/utils.c (revision 243333) +++ gcc-interface/utils.c (working copy) @@ -1641,10 +1641,7 @@ record_builtin_type (const char *name, t character subtypes with RM_Size = Esize = CHAR_TYPE_SIZE into signed types. The idea is to ensure that the bit pattern contained in the Esize'd objects is not changed, even though the numerical value will - be interpreted differently depending on the signedness. - - For character types, the bounds are implicit and, therefore, need to - be adjusted. Morever, the debug info needs the unsigned version. */ + be interpreted differently depending on the signedness. */ void finish_character_type (tree char_type) @@ -1658,11 +1655,32 @@ finish_character_type (tree char_type) ? unsigned_char_type_node : copy_type (gnat_unsigned_type_for (char_type))); + /* Create an unsigned version of the type and set it as debug type. */ TYPE_NAME (unsigned_char_type) = TYPE_NAME (char_type); TYPE_STRING_FLAG (unsigned_char_type) = TYPE_STRING_FLAG (char_type); TYPE_ARTIFICIAL (unsigned_char_type) = TYPE_ARTIFICIAL (char_type); - SET_TYPE_DEBUG_TYPE (char_type, unsigned_char_type); + + /* If this is a subtype, make the debug type a subtype of the debug type + of the base type and convert literal bounds to unsigned. */ + if (TREE_TYPE (char_type)) + { + tree base_unsigned_char_type = TYPE_DEBUG_TYPE (TREE_TYPE (char_type)); + tree min_value = TYPE_MIN_VALUE (char_type); + tree max_value = TYPE_MAX_VALUE (char_type); + + if (TREE_CODE (min_value) == INTEGER_CST) + min_value = fold_convert (base_unsigned_char_type, min_value); + if (TREE_CODE (max_value) == INTEGER_CST) + max_value = fold_convert (base_unsigned_char_type, max_value); + + TREE_TYPE (unsigned_char_type) = base_unsigned_char_type; + SET_TYPE_RM_MIN_VALUE (unsigned_char_type, min_value); + SET_TYPE_RM_MAX_VALUE (unsigned_char_type, max_value); + } + + /* Adjust the bounds of the original type to unsigned; that's especially + important for types since they are implicit in this case. */ SET_TYPE_RM_MIN_VALUE (char_type, TYPE_MIN_VALUE (unsigned_char_type)); SET_TYPE_RM_MAX_VALUE (char_type, TYPE_MAX_VALUE (unsigned_char_type)); }