Merge pull request #1118 from xorgy/only-swizzle-numbers-and-bools
Only try swizzles on vectors, numbers, and booleans.
diff --git a/Test/baseResults/numeral.frag.out b/Test/baseResults/numeral.frag.out
index 11def12..c1e3134 100644
--- a/Test/baseResults/numeral.frag.out
+++ b/Test/baseResults/numeral.frag.out
@@ -11,7 +11,9 @@
ERROR: 0:88: '' : float literal needs a decimal point or exponent
ERROR: 0:98: '' : numeric literal too big
ERROR: 0:101: '' : numeric literal too big
-ERROR: 12 compilation errors. No code generated.
+ERROR: 0:104: '#' : preprocessor directive cannot be preceded by another token
+ERROR: 0:104: '' : syntax error, unexpected $end, expecting COMMA or SEMICOLON
+ERROR: 14 compilation errors. No code generated.
Shader version: 400
@@ -417,6 +419,7 @@
0:? 'g4' ( global int)
0:? 'g5' ( global int)
0:? 'g6' ( global int)
+0:? 'inf1' ( global float)
Linked fragment stage:
@@ -825,4 +828,5 @@
0:? 'g4' ( global int)
0:? 'g5' ( global int)
0:? 'g6' ( global int)
+0:? 'inf1' ( global float)
diff --git a/Test/baseResults/overlongLiteral.frag.out b/Test/baseResults/overlongLiteral.frag.out
new file mode 100644
index 0000000..372d777
--- /dev/null
+++ b/Test/baseResults/overlongLiteral.frag.out
@@ -0,0 +1,19 @@
+overlongLiteral.frag
+ERROR: 0:1: '' : hexadecimal literal too long
+ERROR: 0:1: '' : syntax error, unexpected INTCONSTANT
+ERROR: 2 compilation errors. No code generated.
+
+
+Shader version: 100
+ERROR: node is still EOpNull!
+0:? Linker Objects
+
+
+Linked fragment stage:
+
+ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
+
+Shader version: 100
+ERROR: node is still EOpNull!
+0:? Linker Objects
+
diff --git a/Test/numeral.frag b/Test/numeral.frag
index cc0862c..39814f4 100644
--- a/Test/numeral.frag
+++ b/Test/numeral.frag
@@ -101,3 +101,6 @@
int g4 = 4294967296; // ERROR, too big
int g5 = 4294967295;
int g6 = 4294967294;
+float inf1 = -1.#INF;
+float inf2 = 1.#INF;
+float inf3 = +1.#INF;
diff --git a/Test/overlongLiteral.frag b/Test/overlongLiteral.frag
new file mode 100644
index 0000000..c351ed6
--- /dev/null
+++ b/Test/overlongLiteral.frag
@@ -0,0 +1 @@
+0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
diff --git a/glslang/MachineIndependent/preprocessor/PpScanner.cpp b/glslang/MachineIndependent/preprocessor/PpScanner.cpp
index fa01549..b58bbee 100644
--- a/glslang/MachineIndependent/preprocessor/PpScanner.cpp
+++ b/glslang/MachineIndependent/preprocessor/PpScanner.cpp
@@ -128,7 +128,7 @@
ch = getChar();
// 1.#INF or -1.#INF
- if (ch == '#') {
+ if (parseContext.intermediate.getSource() == EShSourceHlsl && ch == '#') {
if ((len < 2) ||
(len == 2 && ppToken->name[0] != '1') ||
(len == 3 && ppToken->name[1] != '1' && !(ppToken->name[0] == '-' || ppToken->name[0] == '+')) ||
@@ -420,7 +420,7 @@
ival = 0;
do {
- if (ival <= 0x0fffffffu || (enableInt64 && ival <= 0x0fffffffffffffffull)) {
+ if (len < MaxTokenLength && (ival <= 0x0fffffffu || (enableInt64 && ival <= 0x0fffffffffffffffull))) {
ppToken->name[len++] = (char)ch;
if (ch >= '0' && ch <= '9') {
ii = ch - '0';
@@ -433,7 +433,10 @@
ival = (ival << 4) | ii;
} else {
if (! AlreadyComplained) {
- pp->parseContext.ppError(ppToken->loc, "hexadecimal literal too big", "", "");
+ if(len < MaxTokenLength)
+ pp->parseContext.ppError(ppToken->loc, "hexadecimal literal too big", "", "");
+ else
+ pp->parseContext.ppError(ppToken->loc, "hexadecimal literal too long", "", "");
AlreadyComplained = 1;
}
ival = 0xffffffffffffffffull;
diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp
index d8510aa..9ca88ff 100644
--- a/gtests/AST.FromFile.cpp
+++ b/gtests/AST.FromFile.cpp
@@ -183,6 +183,7 @@
"matrix2.frag",
"newTexture.frag",
"Operations.frag",
+ "overlongLiteral.frag",
"prepost.frag",
"simpleFunctionCall.frag",
"structAssignment.frag",