From patchwork Thu Jun 17 07:58:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 55981 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 A93A31007D3 for ; Thu, 17 Jun 2010 17:58:06 +1000 (EST) Received: (qmail 22547 invoked by alias); 17 Jun 2010 07:58:04 -0000 Received: (qmail 22537 invoked by uid 22791); 17 Jun 2010 07:58:04 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_CX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 17 Jun 2010 07:57:59 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5H7vwdY027098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 Jun 2010 03:57:58 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5H7vvrU022376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 17 Jun 2010 03:57:58 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o5H7wDZu024095; Thu, 17 Jun 2010 09:58:13 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o5H7wCMh024093; Thu, 17 Jun 2010 09:58:12 +0200 Date: Thu, 17 Jun 2010 09:58:12 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Emit DW_ATE_UTF for char16_t/char32_t Message-ID: <20100617075812.GR7811@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes 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 Hi! The final DWARF4 version now has DW_ATE_UTF value, so this patch makes sure it is used for char16_t and char32_t (only in C++ so far, in C we don't have such a builtin type). The name based discovery is perhaps ugly, but we don't have enough bits to waste to add TYPE_UTF_FLAG (like TYPE_STRING_FLAG) and adding a langhook for that is IMHO overkill. But if you wish to go that way, it is possible too. 2010-06-17 Jakub Jelinek * dwarf2.h (enum dwarf_type): Add DW_ATE_UTF. * dwarf2out.c (base_type_die): Use DW_ATE_UTF for C++ char16_t and char32_t. Jakub --- include/dwarf2.h.jj 2010-06-09 13:42:16.000000000 +0200 +++ include/dwarf2.h 2010-06-17 08:33:07.000000000 +0200 @@ -654,6 +654,8 @@ enum dwarf_type DW_ATE_signed_fixed = 0xd, DW_ATE_unsigned_fixed = 0xe, DW_ATE_decimal_float = 0xf, + /* DWARF 4. */ + DW_ATE_UTF = 0x10, DW_ATE_lo_user = 0x80, DW_ATE_hi_user = 0xff, --- gcc/dwarf2out.c.jj 2010-06-17 08:17:11.000000000 +0200 +++ gcc/dwarf2out.c 2010-06-17 09:17:12.000000000 +0200 @@ -12377,6 +12377,21 @@ base_type_die (tree type) switch (TREE_CODE (type)) { case INTEGER_TYPE: + if ((dwarf_version >= 4 || !dwarf_strict) + && is_cxx () + && TYPE_NAME (type) + && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL + && DECL_SOURCE_LOCATION (TYPE_NAME (type)) == BUILTINS_LOCATION + && DECL_NAME (TYPE_NAME (type))) + { + const char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); + if (strcmp (name, "char16_t") == 0 + || strcmp (name, "char32_t") == 0) + { + encoding = DW_ATE_UTF; + break; + } + } if (TYPE_STRING_FLAG (type)) { if (TYPE_UNSIGNED (type))