From patchwork Thu Feb 15 19:48:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoni Boucher X-Patchwork-Id: 201722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp81515dyb; Thu, 15 Feb 2024 11:49:35 -0800 (PST) X-Forwarded-Encrypted: i=4; AJvYcCWMShLFpGTK4cWflZLFWtrIoVm4/2s23aCewdLMi81vSw2Os2rPSOm9R9E0xmyoUBG946drPWiPw9cWNzE1yHps2Mr6uQ== X-Google-Smtp-Source: AGHT+IHKAubFaIs/h3zpa1G9jNzNAFGABezEyu9AITSeY3vN+0bDl607/PnijEBorfo/nvJOjMNI X-Received: by 2002:a0c:aad7:0:b0:68e:fd13:7c39 with SMTP id g23-20020a0caad7000000b0068efd137c39mr3312331qvb.34.1708026575235; Thu, 15 Feb 2024 11:49:35 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1708026575; cv=pass; d=google.com; s=arc-20160816; b=dgP5Poi2w0RP6FbtRY87sj15BnGLPzQbWnszyPZQSEoreFMJBRwTxFHvXrt7bq7zhq e22hAUAD8WN45ElENRCCFgS9NBE+xcyS8wkD3ZqIPkYVFs9UWBftM3linWnJ4oLrHbNc YNGxcjs2p1s1R5ogqETOeiSae68k/k8Y7DdWVVOexwiOfK1LH8pLMem+SdK3dU2oBlRf 16X1Ek228bu4LK7hwtgLNxDks967VKE4NmieB0fpoHg8POshcbKaTIRnaUPxGFfkT7jR +zfIoag17AkuzdyCyLVNyTgshyhqxxLwYdGJF/5GDgO0HSLPktPzgohL710sqpWwgmlf FH3w== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id:mime-version :user-agent:autocrypt:date:cc:to:from:subject:message-id :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=wQXfu9Ln2Bw3fsV3a6qorMdMVhu/vWvhfD4Qg9pQV6g=; fh=vAsBZubqglMVgYvXuALnbO1gpFxpxAkhTRAP1jtVR04=; b=xNN48LnPXHyX2/w9nBlAsvNGFv2V9aaVuCevmHIW9ZBCHt0shAF+f5Geqwi20Sj5vT 05iJVNEt1yFp+XlRR1tR32bsiPcJ7jjjOhz9cB93dDSJvOBhrTh5ThrU/JZr12IVXEkM JcpwvSBETfa3NhMrZdPqrxKVdsDh4ZoCidrDG0KEOt9lTBnfTsjFCL4QdyLylU8dsm6n jeAIFa0w9kif/OHIWOiMehkFOcGPqVauSEujYeNLyKKBNi7FGmd2EW/L2z7Zu/JimUFT rV+900taIhhhzY7xgkXXcPC1vkAdg1hVDaEkP+hMBSxDpv58JDNFCZMDcVLrzssrY/x5 fveQ==; dara=google.com ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@zoho.com header.s=zm2022 header.b=btgzKhE9; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=zoho.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id eh8-20020a056214186800b0068f2d7f6696si519157qvb.75.2024.02.15.11.49.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 11:49:35 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@zoho.com header.s=zm2022 header.b=btgzKhE9; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=zoho.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E4C6F386D620 for ; Thu, 15 Feb 2024 19:49:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from sender4-pp-o90.zoho.com (sender4-pp-o90.zoho.com [136.143.188.90]) by sourceware.org (Postfix) with ESMTPS id 802E9386C5B0; Thu, 15 Feb 2024 19:48:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 802E9386C5B0 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=zoho.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zoho.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 802E9386C5B0 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=136.143.188.90 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1708026533; cv=pass; b=Mu9dD2OhCaOqpiLC3d+hiEoP4owVgg4OGkhQVivsuDG/9RkNdH9wtJuYbA+hFq/W8+8OJos4rgnU1szPVDpnzAYUGUJ3ZyyjjSDQzLg0Sfc/n708AAMzekYHA0NhBqJsX9b4c1Bshu8/W6mxdhwbnGpUBKomERREuR++LTpFi5o= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1708026533; c=relaxed/simple; bh=rsJM9werDGMGmmOoNwjBSLWx3qYHF7exvbPcIlKD4LM=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=SJ1MtJTpO3l3I7NKqIaRGZlA9kcYrFsAitpuSZfbWbjQEN2tvcuscr5JJfsAszu7VMrKOknSyM7tcfNDxeIPv7nl3HXJsOxOKjf59R4Tk9O8HiT6rgqQPSRU6I3DVMSGAVZZ5D49LmkOb5gPfZ4fb3FtcON1yjJlig8D8htvWio= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1708026526; cv=none; d=zohomail.com; s=zohoarc; b=XLP3C1VFUZyNf/J9ZOlIwjW5GtKI0rWb0I7e2gOZlqshkqT5CmReWqqASde9gYKNrMm1XHwOADJNKHJF8MbeicuLj4D/Kevh2J/MtrSuzFmZL/V6mKLBy9mQrcy72PcNhjxm5qMPP2iPJRObz2DezEOSEB2IXwZbMSOaUFcnCYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708026526; h=Content-Type:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=wQXfu9Ln2Bw3fsV3a6qorMdMVhu/vWvhfD4Qg9pQV6g=; b=IBv2emA2UWG+5w0BpuSM0ObZP6xq61SH2qJ2a80a6K/nG+B0ZlQHNoA5LLKA+PvDyTec5FtIseOCHdfj8hWfmlOuF2RWoZsKI9uD6nfb12Jlz69KkaZ8MVMqYsJ4GvtM71IDXDBYwuxBOwNcwOl7HDIz+abBDv/OlP1mTqs5JQU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=bouanto@zoho.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1708026526; s=zm2022; d=zoho.com; i=bouanto@zoho.com; h=Message-ID:Subject:Subject:From:From:To:To:Cc:Cc:Date:Date:Content-Type:MIME-Version:Feedback-ID:Message-Id:Reply-To; bh=wQXfu9Ln2Bw3fsV3a6qorMdMVhu/vWvhfD4Qg9pQV6g=; b=btgzKhE9OGKm4oC1qM6Grmooc50MacVncy8+UrRKlGUdR4788HpF6eUjkQQLrmbp esbweMdUJUY+U+vMWeJEt6Y+E4DHmLpdlIMvoftCFtcVLZ9a0XpQbRDrwQrEyzCU058 Dixmjw2jvyHjKQIafgqNcbt5VyguAbNNtX9SMyM8= Received: from [192.168.1.172] (38.87.11.6 [38.87.11.6]) by mx.zohomail.com with SMTPS id 1708026525374702.0112256355604; Thu, 15 Feb 2024 11:48:45 -0800 (PST) Message-ID: <6d77f9aeea6039b458b706fa76ad3dab16bf743d.camel@zoho.com> Subject: [PATCH] libgccjit: Do not treat warnings as errors From: Antoni Boucher To: "gcc-patches@gcc.gnu.org" , "jit@gcc.gnu.org" Cc: David Malcolm Date: Thu, 15 Feb 2024 14:48:43 -0500 Autocrypt: addr=bouanto@zoho.com; prefer-encrypt=mutual; keydata=mQENBFOSMLQBCADO5aw6Ys8thMQUNzrwAnfJX2wbgWiz0pQ01DjYj22eeIpChkoZn6LWdt4dieq30u2rFi/yQzJ02foHwI2+aL9rU6xz/x4TwqyRJQGMOqklNc3R+pdXmH4WDQkQDWmLxvc07vu+zb8Tx5A6pMDh4J2ncCEhLEUcH39Yq/yg4eBnFwUX6N7kakvHrnScGNqhnSFCacoJeMJUAR+1G7VBSBd++jmnHLnx3mj7QkRZVECJUw2zqiv1yReCC6GU4SvqLjdqm5ZGeoWOqD/NHjBRoEeOVjzp6M/qOjjWRbkJVqmvgfcD8UytSSqqboR35YFT4L+rZt2ri3T12MJb3i5syCAXABEBAAG0IUFudG9uaSBCb3VjaGVyIDxib3VhbnRvQHpvaG8uY29tPokBVgQTAQgAQAIbIwcLCQgHAwIBBhUIAgkKCwQWAgMBAh4BAheAFiEEOELC4Uw1Jeb66YE6RVeGAwR4zcEFAlz4QM4FCRLMEZoACgkQRVeGAwR4zcFBQQf/afttJrA/puADQZhrDfkgr0MFvq6iB+GCy1b8BkXimk1TOXTPt87YLehSeijNu3JkYhl5eRc87BNfU9J87KfI/KIy6hZxqlDXk16FhW9bw/7wYEA0hpb3MUn7xLElXDT0ZHaD+KTe8Oun7qfzgx5RlL6r/WODf3CkSpO085R/rfeBqDEx9mVlhDWgq6Az3CZoD+3CqiCKVqmDuHTWz4kwrd9AM5eVcLvvLKnZIdoIp+G5Ao6BvaGlZyfenN1iOSjLy2NXNt4MnUt0lUYEP5KSIIRhHQ8xkUbj7eWUmaahkxhNb3fH3sAPwGnRZrPpb4rgYzNmSk63wWMh9M2xk+rLb7kBDQRTkjC0AQgAumZzsAV/UFWI+dpzebQfma36kKYZZFuseant5sq/HWP553XQ/U6ttJiKyN5MpCqtxvCAoRplf42YhlHuFqgf73WJxoJ6Y+sdyqoBSwlR+ gzAneAmsa8gmmY0wawH0Z2leazjKuS7mJjVEQZg0ZGsiCVRGeRnDqFGzDEzDc9ngWKSoTq0fKzlGy1X85OrtmUrvEbhSo6HP+FoeunHkIqrxu3w3vDoFEXxVQlKI6V3I4nCz5n6DB8WR3L7nsiiTnOiGirPw1ngvWFLW86kkA4FJpayc8Xl3va3SLY+2y4yuROboX2DVI4AC/Qeug/mDiBicPxkP6YfUartQRMe6obkEQARAQABiQE8BBgBCAAmAhsMFiEEOELC4Uw1Jeb66YE6RVeGAwR4zcEFAlz4QRsFCRLMEecACgkQRVeGAwR4zcE56ggAgTgrJInBKC+7552Dpccuo6Clh3wZfjlNLv9/6r5lKEbaNzaTrfhPiAP4WgnluIUmj8amOFLFJpj+BAVNOXpZ4D2R3o9ch8z7fot+fW4Yw+PKIxH4I2xEys8ndoEB3aiQwHjKcGIhkIU7uyMJFQr2aWjdTY0gmXw0YZueHOSLgo7uX4XKxB8fEO/yto/Tff2YBAAq+AtNwt+Gh5YS9rZw7rwUTWMi84yVOlc+zRE79E9NJkvdTwX7IJYo64VzIRNfgHsn7QNdVzuM1XIFHl+Glk6cIlI8s6BO7nEoCn3hTF104fQTAO3fEs+XXZOKXo2lk8faowEoPq5r58StrV0nyg== User-Agent: Evolution 3.50.3 MIME-Version: 1.0 X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-1.1.0/208.5.86 Feedback-ID: rr08011228f88a889b9fe93b8c0026d48b0000247f4da9caf493dfd4089669e4004db220eda2d0e4247a1b2ed5:zu080112266ca40c89a44aa2b795173fa100000dd8b7fcd2e3d6fadbdc9dcfbd909bf1f578a20a7bf0d490:rf08011232806efd6f6a958e86b537d3f000009cf8c37dfd983bc9886902707b685c5d883bc42b3d734e9de1585d56b7e336e1544f933c:ZohoMail X-ZohoMailClient: External X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790995673942564493 X-GMAIL-MSGID: 1790995673942564493 Hi. This patch makes libgccjit treat warnings as warnings instead of errors in order to continue the compilation when there are warnings. One thing I'm not sure what to do about is that warnings will keep overriding first_error as long as there are no errors. What behavior should we have here? Thanks for the review. From 755c72478dc5ba8f6920c9ca27559f5d426a41f5 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Mon, 12 Feb 2024 19:49:43 -0400 Subject: [PATCH] libgccjit: Do not treat warnings as errors gcc/jit/ChangeLog: * jit-playback.cc (add_error, add_error_va): Send DK_ERROR to add_error_va. (add_diagnostic): Call add_diagnostic instead of add_error. * jit-recording.cc (DEFINE_DIAGNOSTIC_KIND): New define. (recording::context::add_diagnostic): New function. (recording::context::add_error): Send DK_ERROR to add_error_va. (recording::context::add_error_va): New parameter diagnostic_kind. * jit-recording.h (add_diagnostic): New function. (add_error_va): New parameter diagnostic_kind. * libgccjit.cc (jit_error): Send DK_ERROR to add_error_va. gcc/testsuite/ChangeLog: * jit.dg/test-error-array-bounds.c: Fix test. --- gcc/jit/jit-playback.cc | 13 ++++--- gcc/jit/jit-recording.cc | 35 +++++++++++++++---- gcc/jit/jit-recording.h | 11 ++++-- gcc/jit/libgccjit.cc | 2 +- .../jit.dg/test-error-array-bounds.c | 10 ++---- 5 files changed, 48 insertions(+), 23 deletions(-) diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc index b49bc94442a..6b0522d6f88 100644 --- a/gcc/jit/jit-playback.cc +++ b/gcc/jit/jit-playback.cc @@ -3941,7 +3941,7 @@ add_error (location *loc, const char *fmt, ...) va_list ap; va_start (ap, fmt); m_recording_ctxt->add_error_va (loc ? loc->get_recording_loc () : NULL, - fmt, ap); + DK_ERROR, fmt, ap); va_end (ap); } @@ -3953,13 +3953,12 @@ playback::context:: add_error_va (location *loc, const char *fmt, va_list ap) { m_recording_ctxt->add_error_va (loc ? loc->get_recording_loc () : NULL, - fmt, ap); + DK_ERROR, fmt, ap); } -/* Report a diagnostic up to the jit context as an error, - so that the compilation is treated as a failure. - For now, any kind of diagnostic is treated as an error by the jit - API. */ +/* Report a diagnostic up to the jit context, so that the + compilation is treated as a failure if the diagnostic + is an error. */ void playback::context:: @@ -3989,7 +3988,7 @@ add_diagnostic (diagnostic_context *diag_context, false); } - m_recording_ctxt->add_error (rec_loc, "%s", text); + m_recording_ctxt->add_diagnostic (rec_loc, diagnostic.kind, "%s", text); pp_clear_output_area (pp); } diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc index 4b8e40ec64c..83a8b299b91 100644 --- a/gcc/jit/jit-recording.cc +++ b/gcc/jit/jit-recording.cc @@ -31,6 +31,14 @@ along with GCC; see the file COPYING3. If not see #include "jit-playback.h" #include +/* This comes from diagnostic.cc. */ +static const char *const diagnostic_kind_text[] = { +#define DEFINE_DIAGNOSTIC_KIND(K, T, C) (T), +#include "diagnostic.def" +#undef DEFINE_DIAGNOSTIC_KIND + "must-not-happen" +}; + namespace gcc { namespace jit { @@ -1664,12 +1672,22 @@ recording::context::get_target_info () /* Format the given error using printf's conventions, print it to stderr, and add it to the context. */ +void +recording::context::add_diagnostic (location *loc, diagnostic_t diagnostic_kind, + const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + add_error_va (loc, diagnostic_kind, fmt, ap); + va_end (ap); +} + void recording::context::add_error (location *loc, const char *fmt, ...) { va_list ap; va_start (ap, fmt); - add_error_va (loc, fmt, ap); + add_error_va (loc, DK_ERROR, fmt, ap); va_end (ap); } @@ -1677,7 +1695,8 @@ recording::context::add_error (location *loc, const char *fmt, ...) it to stderr, and add it to the context. */ void -recording::context::add_error_va (location *loc, const char *fmt, va_list ap) +recording::context::add_error_va (location *loc, diagnostic_t diagnostic_kind, + const char *fmt, va_list ap) { int len; char *malloced_msg; @@ -1698,7 +1717,8 @@ recording::context::add_error_va (location *loc, const char *fmt, va_list ap) has_ownership = true; } if (get_logger ()) - get_logger ()->log ("error %i: %s", m_error_count, errmsg); + get_logger ()->log ("%s %i: %s", diagnostic_kind_text[diagnostic_kind], + m_error_count, errmsg); const char *ctxt_progname = get_str_option (GCC_JIT_STR_OPTION_PROGNAME); @@ -1710,13 +1730,15 @@ recording::context::add_error_va (location *loc, const char *fmt, va_list ap) if (print_errors_to_stderr) { if (loc) - fprintf (stderr, "%s: %s: error: %s\n", + fprintf (stderr, "%s: %s: %s: %s\n", ctxt_progname, loc->get_debug_string (), + diagnostic_kind_text[diagnostic_kind], errmsg); else - fprintf (stderr, "%s: error: %s\n", + fprintf (stderr, "%s: %s: %s\n", ctxt_progname, + diagnostic_kind_text[diagnostic_kind], errmsg); } @@ -1732,7 +1754,8 @@ recording::context::add_error_va (location *loc, const char *fmt, va_list ap) m_last_error_str = const_cast (errmsg); m_owns_last_error_str = has_ownership; - m_error_count++; + if (diagnostic_kind == DK_ERROR) + m_error_count++; } /* Get the message for the first error that occurred on this context, or diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index c47f485dcdc..4833b2d3f52 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see #include "jit-common.h" #include "jit-logging.h" +#include "diagnostic-core.h" #include "libgccjit.h" #include @@ -320,13 +321,19 @@ public: void get_target_info (); + void + add_diagnostic (location *loc, diagnostic_t diagnostic_kind, + const char *fmt, ...) + GNU_PRINTF(4, 5); + void add_error (location *loc, const char *fmt, ...) GNU_PRINTF(3, 4); void - add_error_va (location *loc, const char *fmt, va_list ap) - GNU_PRINTF(3, 0); + add_error_va (location *loc, diagnostic_t diagnostic_kind, const char *fmt, + va_list ap) + GNU_PRINTF(4, 0); const char * get_first_error () const; diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc index ad029253158..5a1308b2b8c 100644 --- a/gcc/jit/libgccjit.cc +++ b/gcc/jit/libgccjit.cc @@ -341,7 +341,7 @@ jit_error (gcc::jit::recording::context *ctxt, va_start (ap, fmt); if (ctxt) - ctxt->add_error_va (loc, fmt, ap); + ctxt->add_error_va (loc, DK_ERROR, fmt, ap); else { /* No context? Send to stderr. */ diff --git a/gcc/testsuite/jit.dg/test-error-array-bounds.c b/gcc/testsuite/jit.dg/test-error-array-bounds.c index a0dead13cb7..fb5c2064177 100644 --- a/gcc/testsuite/jit.dg/test-error-array-bounds.c +++ b/gcc/testsuite/jit.dg/test-error-array-bounds.c @@ -64,11 +64,7 @@ create_code (gcc_jit_context *ctxt, void *user_data) void verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) { - /* Verify that the diagnostic led to the context failing... */ - CHECK_VALUE (result, NULL); - - /* ...and that the message was captured by the API. */ - CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), - "array subscript 10 is above array bounds of" - " 'char[10]' [-Warray-bounds=]"); + /* Verify that the message was captured by the API. */ + CHECK_STRING_VALUE (gcc_jit_context_get_last_error (ctxt), + "while referencing 'buffer'"); } -- 2.43.0