Author: tkreuzer
Date: Thu Feb 20 20:20:26 2014
New Revision: 62268
URL:
http://svn.reactos.org/svn/reactos?rev=62268&view=rev
Log:
[PSEH2_TEST]
Add another test for non-volatile values. Note that PSEH does NOT work like real SEH here,
but this is expected and can not be fixed without special compiler support. Do NEVER DO
this kind of stuff inside SEH blocks! Use volatile variables in this case.
Modified:
trunk/rostests/tests/pseh2/psehtest.c
Modified: trunk/rostests/tests/pseh2/psehtest.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/tests/pseh2/psehtest.c?re…
==============================================================================
--- trunk/rostests/tests/pseh2/psehtest.c [iso-8859-1] (original)
+++ trunk/rostests/tests/pseh2/psehtest.c [iso-8859-1] Thu Feb 20 20:20:26 2014
@@ -2437,6 +2437,54 @@
_SEH2_END;
return (val == 3) || (val == 4) || (val == 5);
+}
+
+DEFINE_TEST(test_unvolatile_3)
+{
+ int register val1 = 0, val2 = 0;
+
+ _SEH2_TRY
+ {
+ val1 = 1;
+
+ _SEH2_TRY
+ {
+ val2 = 1;
+ *((char*)0xc0000000) = 0;
+ val2 = 2;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ val2 |= 4;
+ }
+ _SEH2_END;
+
+ val1 = 2;
+ *((int*)0xc0000000) = 1;
+ val1 = 3;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ val1 = val1 * val2;
+ }
+ _SEH2_END;
+
+ /* The expected case */
+ if ((val1 == 10) && (val2 == 5))
+ return TRUE;
+
+ /* The compiler can optimize away "val1 = 1" and "val1 = 2" and
+ only use the last "val1 = 3", in this case val1 is still 0
+ when the outer exception handler kicks in */
+ if ((val1 == 0) && (val2 == 5))
+ return TRUE;
+
+ /* Same as above, but this time val2 optimized away */
+ if (((val1 == 8) && (val2 == 4)) ||
+ ((val1 == 0) && (val2 == 4)))
+ return TRUE;
+
+ return FALSE;
}
DEFINE_TEST(test_finally_goto)
@@ -2765,6 +2813,7 @@
USE_TEST(test_unvolatile),
USE_TEST(test_unvolatile_2),
+ USE_TEST(test_unvolatile_3),
USE_TEST(test_finally_goto),
USE_TEST(test_nested_exception),
USE_TEST(test_PSEH3_bug),