From patchwork Mon Mar 11 16:06:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 87046 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E27B3858286 for ; Mon, 11 Mar 2024 16:07:41 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id E16813858D20; Mon, 11 Mar 2024 16:07:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E16813858D20 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E16813858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710173238; cv=none; b=XQYKTAM+yjQRtetB9OAF94F/AB3ZAk4YIr3j08aWCEdRYP6aDAlBtPAPnuVx97Z0izat/86fl8P84/5Z1AcP70CWxclIKoO0Lab2rZV6cFk5sAjM8AeJ4hjEl6SC9CS6pbD3UWqArKL6rqgn3dxssg9MMif8oQm5RiuSsztHslA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710173238; c=relaxed/simple; bh=UnSeAtqLuAWOdRDExyyEdB6eNJ9SG2+HVnc4CLpHttk=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=aRrsyrpxUHJW/lmLayYZN0sxnmNvICLp/qcFSPlSI/ubQMDQPWCcae6tzTFA4jjcD67kwFGLm5uwsS0Zqgp8SWAW4xYOoA9IRz8NHk/KiUMn+6PhM/Qnm/i5sko3ITXyQnUCyPaMBS1o37pU+r5PInduOy0XXOhepuG2vMg0Zt4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smarchi-efficios.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 594C51E0AC; Mon, 11 Mar 2024 12:07:16 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: binutils@sourceware.org, Simon Marchi Subject: [PATCH] gdb: ignore -Wregister instead of -Wdeprecated-register Date: Mon, 11 Mar 2024 12:06:32 -0400 Message-ID: <20240311160715.90270-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3496.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org [I'm CCing binutils because it touches include/diagnostics.h, but the change really only affects GDB, as DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER is only used in GDB.] When building GDB on Centos 7 (which has flex 2.5.37) and Clang, I get: $ make ada-exp.o YACC ada-exp.c LEX ada-lex.c CXX ada-exp.o In file included from /home/smarchi/src/binutils-gdb/gdb/ada-exp.y:1179: :1106:2: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 1106 | register yy_state_type yy_current_state; | ^~~~~~~~ In ada-lex.l, we already use `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER`, which for Clang translates to ignoring `-Wdeprecated-register` [1]. I think that was produced when compiling as C++11, but now that we always compile as C++17, Clang produces a `-Wregister` error [2]. For GCC, `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER` already translates to ignoring `-Wregister`. So, rename `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER` to `DIAGNOSTIC_IGNORE_REGISTER` and ignore `-Wregister` for Clang too. [1] https://releases.llvm.org/17.0.1/tools/clang/docs/DiagnosticsReference.html#wdeprecated-register [2] https://releases.llvm.org/17.0.1/tools/clang/docs/DiagnosticsReference.html#wregister include/ChangeLog: * diagnostics.h (DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER): Rename to... (DIAGNOSTIC_IGNORE_REGISTER): ... this. Ignore `-Wregister` instead of `-Wdeprecated-register`. Change-Id: I8a4a51c7222c68577fa22ecacdddfcba32d9dbc5 --- gdb/ada-lex.l | 10 ++++------ include/diagnostics.h | 11 +++++------ 2 files changed, 9 insertions(+), 12 deletions(-) base-commit: b792eb47f25f577ccef365fc9a5c20d55fad42d5 diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 828ff9a9215a..887527600b32 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -48,13 +48,11 @@ NOT_COMPLETE [^\001] #include "diagnostics.h" -/* Some old versions of flex generate code that uses the "register" keyword, - which clang warns about. This was observed for example with flex 2.5.35, - as shipped with macOS 10.12. The same happens with flex 2.5.37 and g++ 11 - which defaults to ISO C++17, that does not allow register storage class - specifiers. */ +/* Some old versions of flex (2.5.x) generate code that uses the "register" + keyword, which compilers warn about, because it is not allowed in ISO + C++17. */ DIAGNOSTIC_PUSH -DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER +DIAGNOSTIC_IGNORE_REGISTER #define NUMERAL_WIDTH 256 #define LONGEST_SIGN ((ULONGEST) 1 << (sizeof(LONGEST) * HOST_CHAR_BIT - 1)) diff --git a/include/diagnostics.h b/include/diagnostics.h index 8cc2b493d2c0..97e30ab807f4 100644 --- a/include/diagnostics.h +++ b/include/diagnostics.h @@ -53,8 +53,8 @@ # define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move") # define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \ DIAGNOSTIC_IGNORE ("-Wdeprecated-declarations") -# define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER \ - DIAGNOSTIC_IGNORE ("-Wdeprecated-register") +# define DIAGNOSTIC_IGNORE_REGISTER DIAGNOSTIC_IGNORE ("-Wregister") + # if __has_warning ("-Wenum-compare-switch") # define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES \ DIAGNOSTIC_IGNORE ("-Wenum-compare-switch") @@ -87,8 +87,7 @@ DIAGNOSTIC_IGNORE ("-Wdeprecated-declarations") # if __GNUC__ >= 7 -# define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER \ - DIAGNOSTIC_IGNORE ("-Wregister") +# define DIAGNOSTIC_IGNORE_REGISTER DIAGNOSTIC_IGNORE ("-Wregister") # endif # define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \ @@ -128,8 +127,8 @@ # define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS #endif -#ifndef DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER -# define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER +#ifndef DIAGNOSTIC_IGNORE_REGISTER +# define DIAGNOSTIC_IGNORE_REGISTER #endif #ifndef DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES