https://git.reactos.org/?p=reactos.git;a=commitdiff;h=96a2b1890390d3c8451dff6eff64ac13d6124d36

commit 96a2b1890390d3c8451dff6eff64ac13d6124d36
Author:     Jérôme Gardou <[email protected]>
AuthorDate: Wed Apr 21 19:50:31 2021 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Wed Apr 28 13:10:23 2021 +0200

    [PSEH] Make the dummy PSEH at least usable.
    
    Not screwing the code flow when no exception happens would be the least
---
 sdk/include/reactos/libs/pseh/pseh2.h | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/sdk/include/reactos/libs/pseh/pseh2.h 
b/sdk/include/reactos/libs/pseh/pseh2.h
index 8437bbe2f7a..45f872e7757 100644
--- a/sdk/include/reactos/libs/pseh/pseh2.h
+++ b/sdk/include/reactos/libs/pseh/pseh2.h
@@ -42,15 +42,36 @@
 extern int _SEH2_Volatile0;
 extern int _SEH2_VolatileExceptionCode;
 
-#define _SEH2_TRY  {
-#define _SEH2_FINALLY }  {
-#define _SEH2_EXCEPT(...) } if (_SEH2_Volatile0 || (0 && (__VA_ARGS__))) {
-#define _SEH2_END }
+#define _SEH2_TRY                                   \
+_Pragma("GCC diagnostic push")                      \
+_Pragma("GCC diagnostic ignored \"-Wunused-label\"")\
+{                                                   \
+    __label__ __seh2_scope_end__;
+
+#define _SEH2_FINALLY                               \
+    __seh2_scope_end__:;                            \
+    }                                               \
+    if (1)                                          \
+    {                                               \
+        __label__ __seh2_scope_end__;
+
+#define _SEH2_EXCEPT(...)                           \
+    __seh2_scope_end__:;                            \
+    }                                               \
+    if (_SEH2_Volatile0 || (0 && (__VA_ARGS__)))    \
+    {                                               \
+        __label__ __seh2_scope_end__;
+
+#define _SEH2_END                                   \
+    __seh2_scope_end__:;                            \
+    }                                               \
+_Pragma("GCC diagnostic pop")
+
 #define _SEH2_GetExceptionInformation() ((struct _EXCEPTION_POINTERS*)0)
 #define _SEH2_GetExceptionCode() _SEH2_VolatileExceptionCode
 #define _SEH2_AbnormalTermination() (0)
 #define _SEH2_YIELD(STMT_) STMT_
-#define _SEH2_LEAVE
+#define _SEH2_LEAVE goto __seh2_scope_end__;
 #define _SEH2_VOLATILE volatile
 
 #elif defined(_USE_PSEH3)

Reply via email to