Merge pull request #1113 from xorgy/preprocessor-int-min-over-negative-one
Preprocessor: Evaluate INT_MIN / -1 to 0.
This commit is contained in:
commit
3112b5686d
14
Test/baseResults/cppIntMinOverNegativeOne.frag.out
Normal file
14
Test/baseResults/cppIntMinOverNegativeOne.frag.out
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
cppIntMinOverNegativeOne.frag
|
||||||
|
Shader version: 100
|
||||||
|
0:? Sequence
|
||||||
|
0:? Linker Objects
|
||||||
|
|
||||||
|
|
||||||
|
Linked fragment stage:
|
||||||
|
|
||||||
|
ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
|
||||||
|
|
||||||
|
Shader version: 100
|
||||||
|
0:? Sequence
|
||||||
|
0:? Linker Objects
|
||||||
|
|
3
Test/cppIntMinOverNegativeOne.frag
Normal file
3
Test/cppIntMinOverNegativeOne.frag
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#if (-2147483648 / -1) != 0
|
||||||
|
#error INT_MIN / -1 should yield 0, something went wrong.
|
||||||
|
#endif
|
@ -84,6 +84,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
#include "PpContext.h"
|
#include "PpContext.h"
|
||||||
#include "PpTokens.h"
|
#include "PpTokens.h"
|
||||||
@ -350,7 +351,7 @@ namespace {
|
|||||||
int op_add(int a, int b) { return a + b; }
|
int op_add(int a, int b) { return a + b; }
|
||||||
int op_sub(int a, int b) { return a - b; }
|
int op_sub(int a, int b) { return a - b; }
|
||||||
int op_mul(int a, int b) { return a * b; }
|
int op_mul(int a, int b) { return a * b; }
|
||||||
int op_div(int a, int b) { return a / b; }
|
int op_div(int a, int b) { return a == INT_MIN && b == -1 ? 0 : a / b; }
|
||||||
int op_mod(int a, int b) { return a % b; }
|
int op_mod(int a, int b) { return a % b; }
|
||||||
int op_pos(int a) { return a; }
|
int op_pos(int a) { return a; }
|
||||||
int op_neg(int a) { return -a; }
|
int op_neg(int a) { return -a; }
|
||||||
|
@ -78,6 +78,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
"matrixError.vert",
|
"matrixError.vert",
|
||||||
"cppSimple.vert",
|
"cppSimple.vert",
|
||||||
"cppIndent.vert",
|
"cppIndent.vert",
|
||||||
|
"cppIntMinOverNegativeOne.frag",
|
||||||
"cppNest.vert",
|
"cppNest.vert",
|
||||||
"cppBad.vert",
|
"cppBad.vert",
|
||||||
"cppBad2.vert",
|
"cppBad2.vert",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user