public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Arthur Cohen <arthur.cohen@embecosm.com>
To: gcc-patches@gcc.gnu.org
Cc: gcc-rust@gcc.gnu.org, dmalcolm@redhat.com
Subject: [PATCH 1/2] diagnostics: add error_meta
Date: Wed,  6 Sep 2023 15:53:02 +0200	[thread overview]
Message-ID: <20230906135303.3643659-2-arthur.cohen@embecosm.com> (raw)
In-Reply-To: <20230906135303.3643659-1-arthur.cohen@embecosm.com>

From: David Malcolm <dmalcolm@redhat.com>

---
 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.  */
-- 
2.40.0


  reply	other threads:[~2023-09-06 13:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06 13:53 [PATCHSET] Add error metadata to diagnostics Arthur Cohen
2023-09-06 13:53 ` Arthur Cohen [this message]
2023-09-06 14:12   ` [PATCH 1/2] diagnostics: add error_meta David Malcolm
2023-09-06 14:24     ` Arthur Cohen
2023-09-06 13:53 ` [PATCH 2/2] Experiment with adding an error code to an error Arthur Cohen
2023-09-06 14:19   ` David Malcolm
2023-09-07  9:39 ` [PATCHSET] Add error metadata to diagnostics Arthur Cohen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230906135303.3643659-2-arthur.cohen@embecosm.com \
    --to=arthur.cohen@embecosm.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gcc-rust@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).