Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
5bdf49cd
Commit
5bdf49cd
authored
May 09, 2016
by
GregF
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix check for non-positive array size
parent
d3d3ce71
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
4 deletions
+42
-4
negativeArraySize.comp.out
Test/baseResults/negativeArraySize.comp.out
+24
-0
negativeArraySize.comp
Test/negativeArraySize.comp
+10
-0
testlist
Test/testlist
+1
-0
ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.cpp
+7
-4
No files found.
Test/baseResults/negativeArraySize.comp.out
0 → 100644
View file @
5bdf49cd
negativeArraySize.comp
Warning, version 310 is not yet complete; most version-specific features are present, but some are missing.
ERROR: 0:9: '' : array size must be a positive integer
ERROR: 1 compilation errors. No code generated.
Shader version: 310
local_size = (1, 1, 1)
ERROR: node is still EOpNull!
0:7 Function Definition: main( (global void)
0:7 Function Parameters:
0:? Linker Objects
Linked compute stage:
Shader version: 310
local_size = (1, 1, 1)
ERROR: node is still EOpNull!
0:7 Function Definition: main( (global void)
0:7 Function Parameters:
0:? Linker Objects
Test/negativeArraySize.comp
0 → 100644
View file @
5bdf49cd
#version 310 es
#ifdef GL_ES
precision mediump float;
#endif
void main()
{
float f[-2]; // cannot declare arrays with negative size
}
Test/testlist
View file @
5bdf49cd
...
@@ -128,4 +128,5 @@ varyingArrayIndirect.frag
...
@@ -128,4 +128,5 @@ varyingArrayIndirect.frag
voidFunction.frag
voidFunction.frag
whileLoop.frag
whileLoop.frag
nonVulkan.frag
nonVulkan.frag
negativeArraySize.comp
spv.atomic.comp
spv.atomic.comp
glslang/MachineIndependent/ParseHelper.cpp
View file @
5bdf49cd
...
@@ -2869,13 +2869,14 @@ bool TParseContext::containsFieldWithBasicType(const TType& type, TBasicType bas
...
@@ -2869,13 +2869,14 @@ bool TParseContext::containsFieldWithBasicType(const TType& type, TBasicType bas
void
TParseContext
::
arraySizeCheck
(
const
TSourceLoc
&
loc
,
TIntermTyped
*
expr
,
TArraySize
&
sizePair
)
void
TParseContext
::
arraySizeCheck
(
const
TSourceLoc
&
loc
,
TIntermTyped
*
expr
,
TArraySize
&
sizePair
)
{
{
bool
isConst
=
false
;
bool
isConst
=
false
;
sizePair
.
size
=
1
;
sizePair
.
node
=
nullptr
;
sizePair
.
node
=
nullptr
;
int
size
=
1
;
TIntermConstantUnion
*
constant
=
expr
->
getAsConstantUnion
();
TIntermConstantUnion
*
constant
=
expr
->
getAsConstantUnion
();
if
(
constant
)
{
if
(
constant
)
{
// handle true (non-specialization) constant
// handle true (non-specialization) constant
size
Pair
.
size
=
constant
->
getConstArray
()[
0
].
getIConst
();
size
=
constant
->
getConstArray
()[
0
].
getIConst
();
isConst
=
true
;
isConst
=
true
;
}
else
{
}
else
{
// see if it's a specialization constant instead
// see if it's a specialization constant instead
...
@@ -2884,16 +2885,18 @@ void TParseContext::arraySizeCheck(const TSourceLoc& loc, TIntermTyped* expr, TA
...
@@ -2884,16 +2885,18 @@ void TParseContext::arraySizeCheck(const TSourceLoc& loc, TIntermTyped* expr, TA
sizePair
.
node
=
expr
;
sizePair
.
node
=
expr
;
TIntermSymbol
*
symbol
=
expr
->
getAsSymbolNode
();
TIntermSymbol
*
symbol
=
expr
->
getAsSymbolNode
();
if
(
symbol
&&
symbol
->
getConstArray
().
size
()
>
0
)
if
(
symbol
&&
symbol
->
getConstArray
().
size
()
>
0
)
size
Pair
.
size
=
symbol
->
getConstArray
()[
0
].
getIConst
();
size
=
symbol
->
getConstArray
()[
0
].
getIConst
();
}
}
}
}
sizePair
.
size
=
size
;
if
(
!
isConst
||
(
expr
->
getBasicType
()
!=
EbtInt
&&
expr
->
getBasicType
()
!=
EbtUint
))
{
if
(
!
isConst
||
(
expr
->
getBasicType
()
!=
EbtInt
&&
expr
->
getBasicType
()
!=
EbtUint
))
{
error
(
loc
,
"array size must be a constant integer expression"
,
""
,
""
);
error
(
loc
,
"array size must be a constant integer expression"
,
""
,
""
);
return
;
return
;
}
}
if
(
size
Pair
.
size
<=
0
)
{
if
(
size
<=
0
)
{
error
(
loc
,
"array size must be a positive integer"
,
""
,
""
);
error
(
loc
,
"array size must be a positive integer"
,
""
,
""
);
return
;
return
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment