Skip to content

Commit 61908c5

Browse files
authored
[orc-rt] Prevent RTTIExtends from being used for errors. (#172250)
Custom error types (ErrorInfoBase subclasses) should use ErrorExtends as of 8f51da3. Adding a static_assert allows us to enforce that at compile-time.
1 parent 5a581ac commit 61908c5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

orc-rt/include/orc-rt/RTTI.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@
5252
#ifndef ORC_RT_RTTI_H
5353
#define ORC_RT_RTTI_H
5454

55+
#include <type_traits>
56+
5557
namespace orc_rt {
5658

59+
class ErrorInfoBase;
60+
5761
template <typename ThisT, typename ParentT> class RTTIExtends;
5862

5963
/// Base class for the extensible RTTI hierarchy.
@@ -107,6 +111,10 @@ class RTTIRoot {
107111
///
108112
template <typename ThisT, typename ParentT> class RTTIExtends : public ParentT {
109113
public:
114+
static_assert(!std::is_base_of_v<ErrorInfoBase, ParentT>,
115+
"RTTIExtends should not be used to define orc_rt custom error "
116+
"types, use ErrorExtends instead");
117+
110118
// Inherit constructors and isA methods from ParentT.
111119
using ParentT::isA;
112120
using ParentT::ParentT;

0 commit comments

Comments
 (0)