From 548ec2c12c30ef2223f7bc3be6504d3e6f467ca4 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Wed, 7 Jan 2015 06:36:55 +0000 Subject: [PATCH] Include ?: in the tests for flow control. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@29348 e7fa87d3-cd2b-0410-9028-fcbf551c1848 --- Test/400.tesc | 2 +- Test/baseResults/150.tesc.out | 27 ++++++++++++++++++++++++++- Test/baseResults/400.tesc.out | 27 ++++++++++++++++++++++++++- glslang/MachineIndependent/glslang.y | 16 ++++++++++------ 4 files changed, 63 insertions(+), 9 deletions(-) diff --git a/Test/400.tesc b/Test/400.tesc index 1f0126cd1..efbcbce5f 100644 --- a/Test/400.tesc +++ b/Test/400.tesc @@ -51,7 +51,7 @@ void main() barrier(); // ERROR break; } - + a < 12 ? a : (barrier(), a); // ERROR { barrier(); } diff --git a/Test/baseResults/150.tesc.out b/Test/baseResults/150.tesc.out index 87e0767d0..1281be810 100644 --- a/Test/baseResults/150.tesc.out +++ b/Test/baseResults/150.tesc.out @@ -223,6 +223,7 @@ ERROR: 0:39: '' : tessellation control barrier() cannot be placed within flow co ERROR: 0:41: '' : tessellation control barrier() cannot be placed within flow control ERROR: 0:46: '' : tessellation control barrier() cannot be placed within flow control ERROR: 0:51: '' : tessellation control barrier() cannot be placed within flow control +ERROR: 0:54: '' : tessellation control barrier() cannot be placed within flow control ERROR: 0:61: '' : tessellation control barrier() cannot be placed after a return from main() ERROR: 0:64: 'vertices' : can only apply to 'out' ERROR: 0:65: 'vertices' : cannot change previously set layout value @@ -232,7 +233,7 @@ ERROR: 0:74: 'in' : type must be an array: ina ERROR: 0:76: '[]' : tessellation input array size must be gl_MaxPatchVertices or implicitly sized ERROR: 0:83: 'location' : overlapping use of location 4 ERROR: 0:87: 'location' : overlapping use of location 4 -ERROR: 17 compilation errors. No code generated. +ERROR: 18 compilation errors. No code generated. Shader version: 400 @@ -366,6 +367,18 @@ ERROR: node is still EOpNull! 0:? Sequence 0:51 Barrier (void) 0:52 Branch: Break +0:54 Test condition and select (int) +0:54 Condition +0:54 Compare Less Than (bool) +0:54 'a' (int) +0:54 Constant: +0:54 12 (const int) +0:54 true case +0:54 'a' (int) +0:54 false case +0:54 Comma (int) +0:54 Barrier (void) +0:54 'a' (int) 0:56 Sequence 0:56 Barrier (void) 0:59 Branch: Return @@ -1100,6 +1113,18 @@ vertices = 4 0:? Sequence 0:51 Barrier (void) 0:52 Branch: Break +0:54 Test condition and select (int) +0:54 Condition +0:54 Compare Less Than (bool) +0:54 'a' (int) +0:54 Constant: +0:54 12 (const int) +0:54 true case +0:54 'a' (int) +0:54 false case +0:54 Comma (int) +0:54 Barrier (void) +0:54 'a' (int) 0:56 Sequence 0:56 Barrier (void) 0:59 Branch: Return diff --git a/Test/baseResults/400.tesc.out b/Test/baseResults/400.tesc.out index af2a414cb..b2beb04bb 100644 --- a/Test/baseResults/400.tesc.out +++ b/Test/baseResults/400.tesc.out @@ -8,6 +8,7 @@ ERROR: 0:39: '' : tessellation control barrier() cannot be placed within flow co ERROR: 0:41: '' : tessellation control barrier() cannot be placed within flow control ERROR: 0:46: '' : tessellation control barrier() cannot be placed within flow control ERROR: 0:51: '' : tessellation control barrier() cannot be placed within flow control +ERROR: 0:54: '' : tessellation control barrier() cannot be placed within flow control ERROR: 0:61: '' : tessellation control barrier() cannot be placed after a return from main() ERROR: 0:64: 'vertices' : can only apply to 'out' ERROR: 0:65: 'vertices' : cannot change previously set layout value @@ -17,7 +18,7 @@ ERROR: 0:74: 'in' : type must be an array: ina ERROR: 0:76: '[]' : tessellation input array size must be gl_MaxPatchVertices or implicitly sized ERROR: 0:83: 'location' : overlapping use of location 4 ERROR: 0:87: 'location' : overlapping use of location 4 -ERROR: 17 compilation errors. No code generated. +ERROR: 18 compilation errors. No code generated. Shader version: 400 @@ -151,6 +152,18 @@ ERROR: node is still EOpNull! 0:? Sequence 0:51 Barrier (void) 0:52 Branch: Break +0:54 Test condition and select (int) +0:54 Condition +0:54 Compare Less Than (bool) +0:54 'a' (int) +0:54 Constant: +0:54 12 (const int) +0:54 true case +0:54 'a' (int) +0:54 false case +0:54 Comma (int) +0:54 Barrier (void) +0:54 'a' (int) 0:56 Sequence 0:56 Barrier (void) 0:59 Branch: Return @@ -337,6 +350,18 @@ ERROR: node is still EOpNull! 0:? Sequence 0:51 Barrier (void) 0:52 Branch: Break +0:54 Test condition and select (int) +0:54 Condition +0:54 Compare Less Than (bool) +0:54 'a' (int) +0:54 Constant: +0:54 12 (const int) +0:54 true case +0:54 'a' (int) +0:54 false case +0:54 Comma (int) +0:54 Barrier (void) +0:54 'a' (int) 0:56 Sequence 0:56 Barrier (void) 0:59 Branch: Return diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y index bda83c569..b60f7facf 100644 --- a/glslang/MachineIndependent/glslang.y +++ b/glslang/MachineIndependent/glslang.y @@ -568,15 +568,19 @@ logical_or_expression conditional_expression : logical_or_expression { $$ = $1; } - | logical_or_expression QUESTION expression COLON assignment_expression { + | logical_or_expression QUESTION { + ++parseContext.controlFlowNestingLevel; + } + expression COLON assignment_expression { + --parseContext.controlFlowNestingLevel; parseContext.boolCheck($2.loc, $1); parseContext.rValueErrorCheck($2.loc, "?", $1); - parseContext.rValueErrorCheck($4.loc, ":", $3); - parseContext.rValueErrorCheck($4.loc, ":", $5); - $$ = parseContext.intermediate.addSelection($1, $3, $5, $2.loc); + parseContext.rValueErrorCheck($5.loc, ":", $4); + parseContext.rValueErrorCheck($5.loc, ":", $6); + $$ = parseContext.intermediate.addSelection($1, $4, $6, $2.loc); if ($$ == 0) { - parseContext.binaryOpError($2.loc, ":", $3->getCompleteString(), $5->getCompleteString()); - $$ = $5; + parseContext.binaryOpError($2.loc, ":", $4->getCompleteString(), $6->getCompleteString()); + $$ = $6; } } ;