Let "#if ((0) + (1) < 2)" understand that '+' isn't a unary operation.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 16 Apr 2013 00:52:22 -0400
changeset 1126 91c22d2de774
parent 1125 3de60f597ebd
child 1127 4d7716f32464
Let "#if ((0) + (1) < 2)" understand that '+' isn't a unary operation.
mojoshader_preprocessor.c
--- a/mojoshader_preprocessor.c	Mon Mar 25 15:34:28 2013 -0400
+++ b/mojoshader_preprocessor.c	Tue Apr 16 00:52:22 2013 -0400
@@ -1691,12 +1691,16 @@
             isleft = 0;
         else if (token == ((Token) '-'))
         {
-            if ((isleft = (previous_token == TOKEN_INT_LITERAL)) == 0)
+            isleft = ((previous_token == TOKEN_INT_LITERAL) ||
+                      (previous_token == ((Token) ')')));
+            if (!isleft)
                 token = TOKEN_PP_UNARY_MINUS;
         } // else if
         else if (token == ((Token) '+'))
         {
-            if ((isleft = (previous_token == TOKEN_INT_LITERAL)) == 0)
+            isleft = ((previous_token == TOKEN_INT_LITERAL) ||
+                      (previous_token == ((Token) ')')));
+            if (!isleft)
                 token = TOKEN_PP_UNARY_PLUS;
         } // else if