From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7905) id B6FDC38582A9; Thu, 7 Sep 2023 09:39:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6FDC38582A9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694079544; bh=SStBXisBeTuhI54u2tw1xTbntun2yHcvjdF+/KGGFes=; h=From:To:Subject:Date:From; b=tImpuP4M9/KqYWygLMC5DLRtYoogDKT+wwUPhVNt3Oo9k9Q1jXi7AgQNGlp43x5jk wNRFD6L0ZZeFpuTOlldj+617qIHX/SHRzExRXqncs4txKkraaW0tL/vF38FJ0sm2ju rmnBDbg7hmSbJsUStyk4YiNVH5IbFjWewMew8B+A= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Arthur Cohen To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-3775] diagnostics: add error_meta X-Act-Checkin: gcc X-Git-Author: David Malcolm X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 18c90eaa25363d34b5bef444fbbad04f5da2522d X-Git-Newrev: 1ad5ae5a45f2e3fc6948b35a3b052fdd48453704 Message-Id: <20230907093904.B6FDC38582A9@sourceware.org> Date: Thu, 7 Sep 2023 09:39:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:1ad5ae5a45f2e3fc6948b35a3b052fdd48453704 commit r14-3775-g1ad5ae5a45f2e3fc6948b35a3b052fdd48453704 Author: David Malcolm Date: Thu Jul 21 18:35:01 2022 -0400 diagnostics: add error_meta gcc/ChangeLog: * diagnostic-core.h (error_meta): New decl. * diagnostic.cc (error_meta): New. Signed-off-by: David Malcolm Diff: --- 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 7334c79e8e6a..c9e27fd2e6e1 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 c523f215baec..65c0cfbf11a5 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. */