Skip to content

Commit f361b68

Browse files
committed
Add [[noreturn]] to CompileTimeErrorReporter::error
1 parent 8511809 commit f361b68

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

python_bindings/src/halide/halide_/PyError.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@ class HalidePythonCompileTimeErrorReporter : public CompileTimeErrorReporter {
1616
halide_python_print(nullptr, msg);
1717
}
1818

19-
void error(const char *msg) override {
19+
[[noreturn]] void error(const char *msg) override {
2020
// This method is called *only* from the Compiler -- never from jitted
2121
// code -- so throwing an Error here is the right thing to do.
22-
2322
throw Error(msg);
24-
25-
// This method must not return!
2623
}
2724
};
2825

python_bindings/stub/PyStubImpl.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ class HalidePythonCompileTimeErrorReporter : public CompileTimeErrorReporter {
3737
py::print(msg, py::arg("end") = "");
3838
}
3939

40-
void error(const char *msg) override {
40+
[[noreturn]] void error(const char *msg) override {
4141
throw Halide::Error(msg);
42-
// This method must not return!
4342
}
4443
};
4544

src/Error.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class CompileTimeErrorReporter {
8383
public:
8484
virtual ~CompileTimeErrorReporter() = default;
8585
virtual void warning(const char *msg) = 0;
86-
virtual void error(const char *msg) = 0;
86+
[[noreturn]] virtual void error(const char *msg) = 0;
8787
};
8888

8989
/** The default error reporter logs to stderr, then throws an exception

test/correctness/custom_error_reporter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class MyCustomErrorReporter : public Halide::CompileTimeErrorReporter {
3333
warnings_occurred++;
3434
}
3535

36-
void error(const char *msg) override {
36+
[[noreturn]] void error(const char *msg) override {
3737
// Emitting "error.*:" to stdout or stderr will cause CMake to report the
3838
// test as a failure on Windows, regardless of error code returned.
3939
// The error text we get from ErrorReport probably contains some variant

0 commit comments

Comments
 (0)