glslang PP: make decimal number parser clearer and add boundary tests. Also, disable the warning for "do {} while (true);"
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31215 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
		
							parent
							
								
									84ea15f444
								
							
						
					
					
						commit
						b06127c513
					
				@ -10,7 +10,9 @@ ERROR: 0:24: '' : octal literal digit too large
 | 
				
			|||||||
ERROR: 0:49: '' : bad digit in hexidecimal literal 
 | 
					ERROR: 0:49: '' : bad digit in hexidecimal literal 
 | 
				
			||||||
ERROR: 0:50: '' : hexidecimal literal too big 
 | 
					ERROR: 0:50: '' : hexidecimal literal too big 
 | 
				
			||||||
ERROR: 0:88: '' : float literal needs a decimal point or exponent 
 | 
					ERROR: 0:88: '' : float literal needs a decimal point or exponent 
 | 
				
			||||||
ERROR: 10 compilation errors.  No code generated.
 | 
					ERROR: 0:98: '' : numeric literal too big 
 | 
				
			||||||
 | 
					ERROR: 0:101: '' : numeric literal too big 
 | 
				
			||||||
 | 
					ERROR: 12 compilation errors.  No code generated.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Shader version: 400
 | 
					Shader version: 400
 | 
				
			||||||
@ -373,6 +375,36 @@ ERROR: node is still EOpNull!
 | 
				
			|||||||
0:88          'e5' (temp float)
 | 
					0:88          'e5' (temp float)
 | 
				
			||||||
0:88          Constant:
 | 
					0:88          Constant:
 | 
				
			||||||
0:88            5.000000
 | 
					0:88            5.000000
 | 
				
			||||||
 | 
					0:98  Sequence
 | 
				
			||||||
 | 
					0:98    move second child to first child (temp uint)
 | 
				
			||||||
 | 
					0:98      'g1' (global uint)
 | 
				
			||||||
 | 
					0:98      Constant:
 | 
				
			||||||
 | 
					0:98        4294967295 (const uint)
 | 
				
			||||||
 | 
					0:99  Sequence
 | 
				
			||||||
 | 
					0:99    move second child to first child (temp uint)
 | 
				
			||||||
 | 
					0:99      'g2' (global uint)
 | 
				
			||||||
 | 
					0:99      Constant:
 | 
				
			||||||
 | 
					0:99        4294967295 (const uint)
 | 
				
			||||||
 | 
					0:100  Sequence
 | 
				
			||||||
 | 
					0:100    move second child to first child (temp uint)
 | 
				
			||||||
 | 
					0:100      'g3' (global uint)
 | 
				
			||||||
 | 
					0:100      Constant:
 | 
				
			||||||
 | 
					0:100        4294967294 (const uint)
 | 
				
			||||||
 | 
					0:101  Sequence
 | 
				
			||||||
 | 
					0:101    move second child to first child (temp int)
 | 
				
			||||||
 | 
					0:101      'g4' (global int)
 | 
				
			||||||
 | 
					0:101      Constant:
 | 
				
			||||||
 | 
					0:101        -1 (const int)
 | 
				
			||||||
 | 
					0:102  Sequence
 | 
				
			||||||
 | 
					0:102    move second child to first child (temp int)
 | 
				
			||||||
 | 
					0:102      'g5' (global int)
 | 
				
			||||||
 | 
					0:102      Constant:
 | 
				
			||||||
 | 
					0:102        -1 (const int)
 | 
				
			||||||
 | 
					0:103  Sequence
 | 
				
			||||||
 | 
					0:103    move second child to first child (temp int)
 | 
				
			||||||
 | 
					0:103      'g6' (global int)
 | 
				
			||||||
 | 
					0:103      Constant:
 | 
				
			||||||
 | 
					0:103        -2 (const int)
 | 
				
			||||||
0:?   Linker Objects
 | 
					0:?   Linker Objects
 | 
				
			||||||
0:?     'c2' (layout(location=2 ) out 4-component vector of float)
 | 
					0:?     'c2' (layout(location=2 ) out 4-component vector of float)
 | 
				
			||||||
0:?     'c3' (layout(location=3 ) out 4-component vector of float)
 | 
					0:?     'c3' (layout(location=3 ) out 4-component vector of float)
 | 
				
			||||||
@ -380,6 +412,12 @@ ERROR: node is still EOpNull!
 | 
				
			|||||||
0:?     'c5' (layout(location=5 ) out 4-component vector of float)
 | 
					0:?     'c5' (layout(location=5 ) out 4-component vector of float)
 | 
				
			||||||
0:?     'c6' (layout(location=6 ) out 4-component vector of float)
 | 
					0:?     'c6' (layout(location=6 ) out 4-component vector of float)
 | 
				
			||||||
0:?     'c7' (layout(location=7 ) out 4-component vector of float)
 | 
					0:?     'c7' (layout(location=7 ) out 4-component vector of float)
 | 
				
			||||||
 | 
					0:?     'g1' (global uint)
 | 
				
			||||||
 | 
					0:?     'g2' (global uint)
 | 
				
			||||||
 | 
					0:?     'g3' (global uint)
 | 
				
			||||||
 | 
					0:?     'g4' (global int)
 | 
				
			||||||
 | 
					0:?     'g5' (global int)
 | 
				
			||||||
 | 
					0:?     'g6' (global int)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Linked fragment stage:
 | 
					Linked fragment stage:
 | 
				
			||||||
@ -745,6 +783,36 @@ ERROR: node is still EOpNull!
 | 
				
			|||||||
0:88          'e5' (temp float)
 | 
					0:88          'e5' (temp float)
 | 
				
			||||||
0:88          Constant:
 | 
					0:88          Constant:
 | 
				
			||||||
0:88            5.000000
 | 
					0:88            5.000000
 | 
				
			||||||
 | 
					0:98  Sequence
 | 
				
			||||||
 | 
					0:98    move second child to first child (temp uint)
 | 
				
			||||||
 | 
					0:98      'g1' (global uint)
 | 
				
			||||||
 | 
					0:98      Constant:
 | 
				
			||||||
 | 
					0:98        4294967295 (const uint)
 | 
				
			||||||
 | 
					0:99  Sequence
 | 
				
			||||||
 | 
					0:99    move second child to first child (temp uint)
 | 
				
			||||||
 | 
					0:99      'g2' (global uint)
 | 
				
			||||||
 | 
					0:99      Constant:
 | 
				
			||||||
 | 
					0:99        4294967295 (const uint)
 | 
				
			||||||
 | 
					0:100  Sequence
 | 
				
			||||||
 | 
					0:100    move second child to first child (temp uint)
 | 
				
			||||||
 | 
					0:100      'g3' (global uint)
 | 
				
			||||||
 | 
					0:100      Constant:
 | 
				
			||||||
 | 
					0:100        4294967294 (const uint)
 | 
				
			||||||
 | 
					0:101  Sequence
 | 
				
			||||||
 | 
					0:101    move second child to first child (temp int)
 | 
				
			||||||
 | 
					0:101      'g4' (global int)
 | 
				
			||||||
 | 
					0:101      Constant:
 | 
				
			||||||
 | 
					0:101        -1 (const int)
 | 
				
			||||||
 | 
					0:102  Sequence
 | 
				
			||||||
 | 
					0:102    move second child to first child (temp int)
 | 
				
			||||||
 | 
					0:102      'g5' (global int)
 | 
				
			||||||
 | 
					0:102      Constant:
 | 
				
			||||||
 | 
					0:102        -1 (const int)
 | 
				
			||||||
 | 
					0:103  Sequence
 | 
				
			||||||
 | 
					0:103    move second child to first child (temp int)
 | 
				
			||||||
 | 
					0:103      'g6' (global int)
 | 
				
			||||||
 | 
					0:103      Constant:
 | 
				
			||||||
 | 
					0:103        -2 (const int)
 | 
				
			||||||
0:?   Linker Objects
 | 
					0:?   Linker Objects
 | 
				
			||||||
0:?     'c2' (layout(location=2 ) out 4-component vector of float)
 | 
					0:?     'c2' (layout(location=2 ) out 4-component vector of float)
 | 
				
			||||||
0:?     'c3' (layout(location=3 ) out 4-component vector of float)
 | 
					0:?     'c3' (layout(location=3 ) out 4-component vector of float)
 | 
				
			||||||
@ -752,4 +820,10 @@ ERROR: node is still EOpNull!
 | 
				
			|||||||
0:?     'c5' (layout(location=5 ) out 4-component vector of float)
 | 
					0:?     'c5' (layout(location=5 ) out 4-component vector of float)
 | 
				
			||||||
0:?     'c6' (layout(location=6 ) out 4-component vector of float)
 | 
					0:?     'c6' (layout(location=6 ) out 4-component vector of float)
 | 
				
			||||||
0:?     'c7' (layout(location=7 ) out 4-component vector of float)
 | 
					0:?     'c7' (layout(location=7 ) out 4-component vector of float)
 | 
				
			||||||
 | 
					0:?     'g1' (global uint)
 | 
				
			||||||
 | 
					0:?     'g2' (global uint)
 | 
				
			||||||
 | 
					0:?     'g3' (global uint)
 | 
				
			||||||
 | 
					0:?     'g4' (global int)
 | 
				
			||||||
 | 
					0:?     'g5' (global int)
 | 
				
			||||||
 | 
					0:?     'g6' (global int)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -94,3 +94,10 @@ layout (location = 04) out vec4 c4;
 | 
				
			|||||||
layout (location = 005u) out vec4 c5;
 | 
					layout (location = 005u) out vec4 c5;
 | 
				
			||||||
layout (location = 0x6) out vec4 c6;
 | 
					layout (location = 0x6) out vec4 c6;
 | 
				
			||||||
layout (location = 0x7u) out vec4 c7;
 | 
					layout (location = 0x7u) out vec4 c7;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint g1 = 4294967296u; // ERROR, too big
 | 
				
			||||||
 | 
					uint g2 = 4294967295u;
 | 
				
			||||||
 | 
					uint g3 = 4294967294u;
 | 
				
			||||||
 | 
					int g4 = 4294967296;   // ERROR, too big
 | 
				
			||||||
 | 
					int g5 = 4294967295;
 | 
				
			||||||
 | 
					int g6 = 4294967294;
 | 
				
			||||||
 | 
				
			|||||||
@ -80,6 +80,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "../ParseHelper.h"
 | 
					#include "../ParseHelper.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma warning(disable : 4127)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace glslang {
 | 
					namespace glslang {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TPpToken {
 | 
					class TPpToken {
 | 
				
			||||||
 | 
				
			|||||||
@ -432,19 +432,21 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
 | 
				
			|||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                // Finish handling signed and unsigned integers
 | 
					                // Finish handling signed and unsigned integers
 | 
				
			||||||
                int numericLen = len;
 | 
					                int numericLen = len;
 | 
				
			||||||
                int uint = 0;
 | 
					                bool uint = false;
 | 
				
			||||||
                if (ch == 'u' || ch == 'U') {
 | 
					                if (ch == 'u' || ch == 'U') {
 | 
				
			||||||
                    if (len < TPpToken::maxTokenLength)
 | 
					                    if (len < TPpToken::maxTokenLength)
 | 
				
			||||||
                        ppToken->name[len++] = (char)ch;
 | 
					                        ppToken->name[len++] = (char)ch;
 | 
				
			||||||
                    uint = 1;
 | 
					                    uint = true;
 | 
				
			||||||
                } else
 | 
					                } else
 | 
				
			||||||
                    pp->ungetChar();
 | 
					                    pp->ungetChar();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                ppToken->name[len] = '\0';				
 | 
					                ppToken->name[len] = '\0';
 | 
				
			||||||
                ival = 0;
 | 
					                ival = 0;
 | 
				
			||||||
                for (ii = 0; ii < numericLen; ii++) {
 | 
					                const unsigned oneTenthMaxInt  = 0xFFFFFFFFu / 10;
 | 
				
			||||||
                    ch = ppToken->name[ii] - '0';
 | 
					                const unsigned remainderMaxInt = 0xFFFFFFFFu - 10 * oneTenthMaxInt;
 | 
				
			||||||
                    if ((ival > 0x19999999u) || (ival == 0x19999999u && ch >= 6)) {
 | 
					                for (int i = 0; i < numericLen; i++) {
 | 
				
			||||||
 | 
					                    ch = ppToken->name[i] - '0';
 | 
				
			||||||
 | 
					                    if ((ival > oneTenthMaxInt) || (ival == oneTenthMaxInt && ch > remainderMaxInt)) {
 | 
				
			||||||
                        pp->parseContext.error(ppToken->loc, "numeric literal too big", "", "");
 | 
					                        pp->parseContext.error(ppToken->loc, "numeric literal too big", "", "");
 | 
				
			||||||
                        ival = 0xFFFFFFFFu;
 | 
					                        ival = 0xFFFFFFFFu;
 | 
				
			||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user