diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-07-11 23:29:50 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-07-11 23:31:02 +0200 |
commit | 70dd5e7c66b1fe3f82e5b4db2406050baba15f05 (patch) | |
tree | 3f012200ef3c934f33db1a4ef2b790fae3141860 /gfx/angle/src/compiler/preprocessor/ExpressionParser.y | |
parent | 3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff) | |
parent | 8481fa25d246f1968d0a254ee3c6cdd82c60781a (diff) | |
download | UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.gz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.lz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.xz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.zip |
Merge branch 'ANGLE-rollback'
This resolves #624
Note: Cherry-picked some fixes on top of the ANGLE version that we want to keep.
Diffstat (limited to 'gfx/angle/src/compiler/preprocessor/ExpressionParser.y')
-rwxr-xr-x | gfx/angle/src/compiler/preprocessor/ExpressionParser.y | 54 |
1 files changed, 12 insertions, 42 deletions
diff --git a/gfx/angle/src/compiler/preprocessor/ExpressionParser.y b/gfx/angle/src/compiler/preprocessor/ExpressionParser.y index 4dbc9e828..dc0080eac 100755 --- a/gfx/angle/src/compiler/preprocessor/ExpressionParser.y +++ b/gfx/angle/src/compiler/preprocessor/ExpressionParser.y @@ -41,15 +41,17 @@ WHICH GENERATES THE GLSL ES preprocessor expression parser. #include <cassert> #include <sstream> -#include <stdint.h> #include "DiagnosticsBase.h" #include "Lexer.h" #include "Token.h" -#include "common/mathutil.h" -typedef int32_t YYSTYPE; -typedef uint32_t UNSIGNED_TYPE; +#if defined(_MSC_VER) +typedef __int64 YYSTYPE; +#else +#include <stdint.h> +typedef intmax_t YYSTYPE; +#endif // _MSC_VER #define YYENABLE_NLS 0 #define YYLTYPE_IS_TRIVIAL 1 @@ -194,7 +196,7 @@ expression $$ = $1 < $3; } | expression TOK_OP_RIGHT expression { - if ($3 < 0 || $3 > 31) + if ($3 < 0) { if (!context->isIgnoringErrors()) { @@ -208,18 +210,13 @@ expression } $$ = static_cast<YYSTYPE>(0); } - else if ($1 < 0) - { - // Logical shift right. - $$ = static_cast<YYSTYPE>(static_cast<UNSIGNED_TYPE>($1) >> $3); - } else { $$ = $1 >> $3; } } | expression TOK_OP_LEFT expression { - if ($3 < 0 || $3 > 31) + if ($3 < 0) { if (!context->isIgnoringErrors()) { @@ -233,21 +230,16 @@ expression } $$ = static_cast<YYSTYPE>(0); } - else if ($1 < 0) - { - // Logical shift left. - $$ = static_cast<YYSTYPE>(static_cast<UNSIGNED_TYPE>($1) << $3); - } else { $$ = $1 << $3; } } | expression '-' expression { - $$ = gl::WrappingDiff<YYSTYPE>($1, $3); + $$ = $1 - $3; } | expression '+' expression { - $$ = gl::WrappingSum<YYSTYPE>($1, $3); + $$ = $1 + $3; } | expression '%' expression { if ($3 == 0) @@ -264,12 +256,6 @@ expression } $$ = static_cast<YYSTYPE>(0); } - else if (($1 == std::numeric_limits<YYSTYPE>::min()) && ($3 == -1)) - { - // Check for the special case where the minimum representable number is - // divided by -1. If left alone this has undefined results. - $$ = 0; - } else { $$ = $1 % $3; @@ -290,20 +276,13 @@ expression } $$ = static_cast<YYSTYPE>(0); } - else if (($1 == std::numeric_limits<YYSTYPE>::min()) && ($3 == -1)) - { - // Check for the special case where the minimum representable number is - // divided by -1. If left alone this leads to integer overflow in C++, which - // has undefined results. - $$ = std::numeric_limits<YYSTYPE>::max(); - } else { $$ = $1 / $3; } } | expression '*' expression { - $$ = gl::WrappingMul($1, $3); + $$ = $1 * $3; } | '!' expression %prec TOK_UNARY { $$ = ! $2; @@ -312,16 +291,7 @@ expression $$ = ~ $2; } | '-' expression %prec TOK_UNARY { - // Check for negation of minimum representable integer to prevent undefined signed int - // overflow. - if ($2 == std::numeric_limits<YYSTYPE>::min()) - { - $$ = std::numeric_limits<YYSTYPE>::min(); - } - else - { - $$ = -$2; - } + $$ = - $2; } | '+' expression %prec TOK_UNARY { $$ = + $2; |