From patchwork Wed Sep 6 13:53:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 137581 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp2323072vqo; Wed, 6 Sep 2023 06:51:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEulcRj+/V31EohRfrPWVVUBsUlDKzFTKEkKR8eqg1a2wAt/+9QtA644OTOZ+y4+6kVLUgk X-Received: by 2002:a17:906:1d9:b0:9a5:c7a6:1549 with SMTP id 25-20020a17090601d900b009a5c7a61549mr2406307ejj.39.1694008261454; Wed, 06 Sep 2023 06:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694008261; cv=none; d=google.com; s=arc-20160816; b=xk/1liWjK7Z5vK00KD0CJBxoOzlM+0VfHnUQ+T1Nlxxjdbk6NoopeC8wj2XZ6oXIuS 4vQ9wxyji8A6S34Vi5vU45vB4uJzlJUQC8VJYdTJqHny8vREPBN2HlCkq07hLvyGUNw8 ow+vHf6jnrHGAjDx6BMp5W0ahMyhN6Nc0RToKPOS1Sg4m6j3yKPTw/v/87XM8mbjZwTW Fx87SGDQHvbWKF+Xh3p2OBg6Vcun8yegwT3394wSMDhKd/TW/5lVt1aC5S/3NbsWg54G NWUdYkF5ZMV2b2UCQCo1evhacRLJpFbjHiR2bZmDoDD/MC+oQyPN+jreg/PmSZgltVJ0 vT+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:dmarc-filter:delivered-to; bh=iZ2/J9wWiX3+Y86nmNymSLSxOFNDt+XfMViaQzFKl+0=; fh=wFq7tT6aDoWtju83L9lDAhBMEFwd5hWtfnM+XVolLD0=; b=O0lZwgPXyeKeBekrrKmNFq5tNKhf77Ajdn6u/iAuw3KHGaekwzQrJxqfAHu5zfjJhm lSIDWtTFBOlnlL2yOYZBxjQP+BzOYqbvSIXVShKaJUQurT30YUXsFt4unc0LeaeBuxWR /HVTV5fak1QWqLrkn4X32y1/Y8WWUc6hIQ5VCutwG76H745Z+PonVcHUPlHHQzlqHRoJ hmgqMCmSHpyyL6LJSRu3ZSETEukJPmwP9clsG5zW2vnpV/vyI2YG6c+SFuXIvNdOS3jI NG2E1SliF+cWUGedY8aSrw+P8iGzL4jIAVo+KxOcjWRyGngwk2zlilCFBn72Sz5Q50Hy 6imQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embecosm.com header.s=google header.b=NF2jwLFX; 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" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hb8-20020a170906b88800b0099bcae257e3si9288608ejb.832.2023.09.06.06.51.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Sep 2023 06:51:01 -0700 (PDT) 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=fail header.i=@embecosm.com header.s=google header.b=NF2jwLFX; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 805D13855583 for ; Wed, 6 Sep 2023 13:50:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 50224385800C for ; Wed, 6 Sep 2023 13:49:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50224385800C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31c6d17aec4so3102678f8f.1 for ; Wed, 06 Sep 2023 06:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1694008179; x=1694612979; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iZ2/J9wWiX3+Y86nmNymSLSxOFNDt+XfMViaQzFKl+0=; b=NF2jwLFXaSFEz0vmxGtXyqPQNGQ0rpH9hnQGSGL4ty9nwAuqqdJGvpOECH1wVwsLCv 3eYwLchgf3SDHSy2OPgL/7oFJAhVhDdzAqin4evoupiBVb6EsGxnGTEaYSXVaAetfKzk 7LMSfpb8li/Pt3dqDb/7iWHkPFcT/JM+NWTL4A2zD6HNKZnCoWns2ZJLMFT7hOx1fnnD wYBh5bSoLhIyLkl5dic0ahV9wxkLmUSi1Wp09tiKGuk8LxFaSMp4fydXlVVPfgXEng2b 9yJvZptXylDMBXFg3cBlf9ogtI6EtICDeLw133GaBBn7tQ47N9wYuPMk/9rhn29mCguu /WfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694008179; x=1694612979; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iZ2/J9wWiX3+Y86nmNymSLSxOFNDt+XfMViaQzFKl+0=; b=Gidtzf5Za7eSML7ii768H2r2+PxclrvGxhFELJjPDzSOEUrwDSiB5lAhYgVgPZOYcS Qw7uCS5DOBsK8tSWsnGBEQQXGNer9o094R4P8RVG1xdosu7PmOoRQfVlnap6EeBoZjCT 3vSOM7ZQkZLhth0W6rd6SbgW9xk814eKBk4yDz2566hOv3oQbGBRTD7ze3cJk25V5Esf bDGAQGHIem4BDTLT3G8ANUjV3v7dI5weNUvodHWDrpyD+Gl0sbN5eAdxBninMyzQMztT yh/J05ew7GBdFsLF5hobjCro08DkDG/noU0cjMezlClrkLuj1J3QrMoUUM9f4lJFZbZR 9/iw== X-Gm-Message-State: AOJu0YwtnBxxGGnqzCNUTP+eiIpm6pAaR5Bmp5vEehix870v0Dx3EOSP knSB1qvqkc/Gdt/hYs2r/TTgWAqK6YA5QxJfQKxC7F8= X-Received: by 2002:a5d:4d8f:0:b0:319:755c:3c1e with SMTP id b15-20020a5d4d8f000000b00319755c3c1emr2137457wru.11.1694008178812; Wed, 06 Sep 2023 06:49:38 -0700 (PDT) Received: from localhost.localdomain ([2001:861:5e4c:3bb0:fa3:84b9:61c0:bf1a]) by smtp.gmail.com with ESMTPSA id k8-20020a5d4288000000b003176aa612b1sm20528505wrq.38.2023.09.06.06.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Sep 2023 06:49:38 -0700 (PDT) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] diagnostics: add error_meta Date: Wed, 6 Sep 2023 15:53:02 +0200 Message-Id: <20230906135303.3643659-2-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230906135303.3643659-1-arthur.cohen@embecosm.com> References: <20230906135303.3643659-1-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable 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: , Cc: gcc-rust@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776296406575101371 X-GMAIL-MSGID: 1776296406575101371 From: David Malcolm Signed-off-by: David Malcolm --- gcc/diagnostic-core.h | 3 +++ gcc/diagnostic.cc | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/gcc/diagnostic-core.h b/gcc/diagnostic-core.h index 7334c79e8e6..c9e27fd2e6e 100644 --- a/gcc/diagnostic-core.h +++ b/gcc/diagnostic-core.h @@ -92,6 +92,9 @@ extern void error_n (location_t, unsigned HOST_WIDE_INT, const char *, extern void error_at (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); extern void error_at (rich_location *, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); +extern void error_meta (rich_location *, const diagnostic_metadata &, + const char *, ...) + ATTRIBUTE_GCC_DIAG(3,4); extern void fatal_error (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3) ATTRIBUTE_NORETURN; /* Pass one of the OPT_W* from options.h as the second parameter. */ diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc index c523f215bae..65c0cfbf11a 100644 --- a/gcc/diagnostic.cc +++ b/gcc/diagnostic.cc @@ -2108,6 +2108,21 @@ error_at (rich_location *richloc, const char *gmsgid, ...) va_end (ap); } +/* Same as above, but with metadata. */ + +void +error_meta (rich_location *richloc, const diagnostic_metadata &metadata, + const char *gmsgid, ...) +{ + gcc_assert (richloc); + + auto_diagnostic_group d; + va_list ap; + va_start (ap, gmsgid); + diagnostic_impl (richloc, &metadata, -1, gmsgid, &ap, DK_ERROR); + va_end (ap); +} + /* "Sorry, not implemented." Use for a language feature which is required by the relevant specification but not implemented by GCC. An object file will not be produced. */