From patchwork Mon Oct 7 17:35:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Terekhov, Mikhail via Gdb-patches" X-Patchwork-Id: 34851 Received: (qmail 96689 invoked by alias); 7 Oct 2019 17:35:18 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 96679 invoked by uid 89); 7 Oct 2019 17:35:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*MI:google X-HELO: mail-qt1-f202.google.com Received: from mail-qt1-f202.google.com (HELO mail-qt1-f202.google.com) (209.85.160.202) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Oct 2019 17:35:16 +0000 Received: by mail-qt1-f202.google.com with SMTP id r15so16017628qtn.12 for ; Mon, 07 Oct 2019 10:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=w32VO/1oJOh4KMbYL9saBMO2NSq/fh0iVsPuxHMEBYI=; b=Fbgv6/+/mukG2JP5pmx2HC+FvE2qTYCdgmKls1goqfv8/oXoVY4ii4gANdSebcoDu7 1yqQoU79u/ODDyIiPjixMFDH2geVWSgGegtLHM6Fke9RTUG61XdlU3gbUY1FVWTThXEe Z3nZ4lyR2m8RmgevfLRpGICVD90bUx3iaDAbMN1IqOS2jRbhzurSwWE7v5W+Ef9UGiYG tl1tJpEsLhuPwrA2TpGj/fOC3mLxQIdQnIek10gYoBBoFTWKahhH4GyJaLcTht9y/0HM opBWJ3zHdKVUKD7H3VKU3gI9E72STltnrIZm02UvBrVbF/jTmcT2Yhn60z5ZCxeL9Ft1 I1DA== Date: Mon, 7 Oct 2019 12:35:10 -0500 Message-Id: <20191007173510.250346-1-cbiesinger@google.com> Mime-Version: 1.0 Subject: [PATCH] Use gdb_static_assert in charset.c X-Patchwork-Original-From: "Christian Biesinger via gdb-patches" From: "Terekhov, Mikhail via Gdb-patches" Reply-To: Christian Biesinger To: gdb-patches@sourceware.org Cc: Christian Biesinger X-IsSubscribed: yes It currently has a "manual" static assert. gdb/ChangeLog: 2019-10-07 Christian Biesinger * charset.c (your_gdb_wchar_t_is_bogus): Replace with a gdb_static_assert. --- gdb/charset.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/gdb/charset.c b/gdb/charset.c index 9df46c0c74d..73131651a6d 100644 --- a/gdb/charset.c +++ b/gdb/charset.c @@ -946,15 +946,9 @@ default_auto_wide_charset (void) #define ENDIAN_SUFFIX "LE" #endif -/* The code below serves to generate a compile time error if - gdb_wchar_t type is not of size 2 nor 4, despite the fact that - macro __STDC_ISO_10646__ is defined. - This is better than a gdb_assert call, because GDB cannot handle - strings correctly if this size is different. */ - -extern char your_gdb_wchar_t_is_bogus[(sizeof (gdb_wchar_t) == 2 - || sizeof (gdb_wchar_t) == 4) - ? 1 : -1]; +/* GDB cannot handle strings correctly if this size is different. */ + +gdb_static_assert (sizeof (gdb_wchar_t) == 2 || sizeof (gdb_wchar_t) == 4); /* intermediate_encoding returns the charset used internally by GDB to convert between target and host encodings. As the test above