From 16f3764cdaee9ded0e3e62f73fa159354c35deb6 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 26 Apr 2022 17:37:31 +0100 Subject: [PATCH] Work around gcc compiler bug * It complains that there is switch fallthrough after an unconditional return, when it's inside a do{}while(0). Simplifying the while condition seems to address it. --- renderdoc/common/result.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/renderdoc/common/result.h b/renderdoc/common/result.h index e56332a97..690f171fc 100644 --- a/renderdoc/common/result.h +++ b/renderdoc/common/result.h @@ -55,35 +55,35 @@ DECLARE_REFLECTION_STRUCT(RDResult); // helper macros since we often want to print the error message that gets returned. // one helper returns immediately, the other sets a result and prints - to allow cleanup -#define RETURN_ERROR_RESULT_INTERNAL(code, msg, ...) \ - do \ - { \ - RDResult res##__LINE__(code, StringFormat::Fmt(STRING_LITERAL(msg), __VA_ARGS__)); \ - RDCERR("%s", res##__LINE__.message.c_str()); \ - return res##__LINE__; \ - } while((void)0, 0) +#define RETURN_ERROR_RESULT_INTERNAL(code, msg, ...) \ + do \ + { \ + RDResult CONCAT(res, __LINE__)(code, StringFormat::Fmt(STRING_LITERAL(msg), __VA_ARGS__)); \ + RDCERR("%s", CONCAT(res, __LINE__).message.c_str()); \ + return CONCAT(res, __LINE__); \ + } while(0) #define SET_ERROR_RESULT_INTERNAL(res, code, msg, ...) \ do \ { \ res = RDResult(code, StringFormat::Fmt(STRING_LITERAL(msg), __VA_ARGS__)); \ RDCERR("%s", res.message.c_str()); \ - } while((void)0, 0) + } while(0) -#define RETURN_WARNING_RESULT_INTERNAL(code, msg, ...) \ - do \ - { \ - RDResult res##__LINE__(code, StringFormat::Fmt(STRING_LITERAL(msg), __VA_ARGS__)); \ - RDCWARN("%s", res##__LINE__.message.c_str()); \ - return res##__LINE__; \ - } while((void)0, 0) +#define RETURN_WARNING_RESULT_INTERNAL(code, msg, ...) \ + do \ + { \ + RDResult CONCAT(res, __LINE__)(code, StringFormat::Fmt(STRING_LITERAL(msg), __VA_ARGS__)); \ + RDCWARN("%s", CONCAT(res, __LINE__).message.c_str()); \ + return CONCAT(res, __LINE__); \ + } while(0) #define SET_WARNING_RESULT_INTERNAL(res, code, msg, ...) \ do \ { \ res = RDResult(code, StringFormat::Fmt(STRING_LITERAL(msg), __VA_ARGS__)); \ RDCWARN("%s", res.message.c_str()); \ - } while((void)0, 0) + } while(0) // VS automatically elides any trailing comma if there are no arguments above. GCC/Clang are // stricter and may fail, so we add an extra 0 since it won't get processed by the format anyway