diff options
| author | Reid Kleckner <rnk@google.com> | 2016-03-24 23:49:34 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2016-03-24 23:49:34 +0000 |
| commit | a15b76b3774e6228bc4ea05851aa2425ca19f7c4 (patch) | |
| tree | 60f967234c66c1055e2da85b53c340f6ad998350 /llvm/unittests/Support/ErrorTest.cpp | |
| parent | d07268c52832948e7d8cd61b53312aa0e14e93f8 (diff) | |
| download | llvm-a15b76b3774e6228bc4ea05851aa2425ca19f7c4.zip llvm-a15b76b3774e6228bc4ea05851aa2425ca19f7c4.tar.gz llvm-a15b76b3774e6228bc4ea05851aa2425ca19f7c4.tar.bz2 | |
Try to fix ODR violation of ErrorInfo::ID
This implements my suggestion to Lang.
llvm-svn: 264360
Diffstat (limited to 'llvm/unittests/Support/ErrorTest.cpp')
| -rw-r--r-- | llvm/unittests/Support/ErrorTest.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp index cf1c6e6..893bd68 100644 --- a/llvm/unittests/Support/ErrorTest.cpp +++ b/llvm/unittests/Support/ErrorTest.cpp @@ -35,6 +35,9 @@ public: llvm_unreachable("CustomError doesn't support ECError conversion"); } + // Used by ErrorInfo::classID. + static char ID; + protected: // This error is subclassed below, but we can't use inheriting constructors // yet, so we can't propagate the constructors through ErrorInfo. Instead @@ -45,6 +48,8 @@ protected: int Info; }; +char CustomError::ID = 0; + // Custom error class with a custom base class and some additional random // 'info'. class CustomSubError : public ErrorInfo<CustomSubError, CustomError> { @@ -66,10 +71,15 @@ public: llvm_unreachable("CustomSubError doesn't support ECError conversion"); } + // Used by ErrorInfo::classID. + static char ID; + protected: int ExtraInfo; }; +char CustomSubError::ID = 0; + static Error handleCustomError(const CustomError &CE) { return Error(); } static void handleCustomErrorVoid(const CustomError &CE) {} @@ -453,6 +463,3 @@ TEST(Error, ErrorCodeConversions) { } } // end anon namespace - -template <> char ErrorInfo<CustomError>::ID = 0; -template <> char ErrorInfo<CustomSubError, CustomError>::ID = 0; |
