From 3979a9010bfb51cd7a4f7f53b1d3a0cb902deeec Mon Sep 17 00:00:00 2001 From: Sam Vervaeck Date: Sun, 21 Jan 2024 01:12:02 +0100 Subject: [PATCH] Dont let `Diagnostic` inherit from `std::runtime_error` We are not using exceptions --- bootstrap/cxx/include/bolt/Diagnostics.hpp | 4 +++- bootstrap/cxx/src/Diagnostics.cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bootstrap/cxx/include/bolt/Diagnostics.hpp b/bootstrap/cxx/include/bolt/Diagnostics.hpp index c301f8739..51361b020 100644 --- a/bootstrap/cxx/include/bolt/Diagnostics.hpp +++ b/bootstrap/cxx/include/bolt/Diagnostics.hpp @@ -23,7 +23,7 @@ namespace bolt { UnificationError, }; - class Diagnostic : std::runtime_error { + class Diagnostic { const DiagnosticKind Kind; @@ -43,6 +43,8 @@ namespace bolt { virtual unsigned getCode() const noexcept = 0; + virtual ~Diagnostic() {} + }; class UnexpectedStringDiagnostic : public Diagnostic { diff --git a/bootstrap/cxx/src/Diagnostics.cc b/bootstrap/cxx/src/Diagnostics.cc index ed4f85654..ff9aeda35 100644 --- a/bootstrap/cxx/src/Diagnostics.cc +++ b/bootstrap/cxx/src/Diagnostics.cc @@ -39,7 +39,7 @@ namespace bolt { Diagnostic::Diagnostic(DiagnosticKind Kind): - std::runtime_error("a compiler error occurred without being caught"), Kind(Kind) {} + Kind(Kind) {} bool sourceLocLessThan(const Diagnostic* L, const Diagnostic* R) { auto N1 = L->getNode();