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
12a38337
Commit
12a38337
authored
Jul 22, 2015
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 32: Guard against constructors consuming unsized arrays.
parent
f4984009
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
12 deletions
+40
-12
array.frag
Test/array.frag
+2
-0
array.frag.out
Test/baseResults/array.frag.out
+16
-1
ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.cpp
+22
-11
No files found.
Test/array.frag
View file @
12a38337
...
@@ -102,3 +102,5 @@ void foo3()
...
@@ -102,3 +102,5 @@ void foo3()
}
}
int
[]
i
=
int
[]();
// ERROR, need constructor arguments
int
[]
i
=
int
[]();
// ERROR, need constructor arguments
float
emptyA
[];
float
b
=
vec4
(
emptyA
);
// ERROR, array can't be a constructor argument
Test/baseResults/array.frag.out
View file @
12a38337
...
@@ -24,7 +24,8 @@ ERROR: 0:93: 'length' : array must be declared with a size before using this me
...
@@ -24,7 +24,8 @@ ERROR: 0:93: 'length' : array must be declared with a size before using this me
ERROR: 0:101: '[' : array index out of range '5'
ERROR: 0:101: '[' : array index out of range '5'
ERROR: 0:104: 'constructor' : array constructor must have at least one argument
ERROR: 0:104: 'constructor' : array constructor must have at least one argument
ERROR: 0:104: '=' : cannot convert from 'const float' to 'global implicitly-sized array of int'
ERROR: 0:104: '=' : cannot convert from 'const float' to 'global implicitly-sized array of int'
ERROR: 25 compilation errors. No code generated.
ERROR: 0:106: 'constructor' : array argument must be sized
ERROR: 26 compilation errors. No code generated.
Shader version: 130
Shader version: 130
...
@@ -258,6 +259,11 @@ ERROR: node is still EOpNull!
...
@@ -258,6 +259,11 @@ ERROR: node is still EOpNull!
0:101 5 (const int)
0:101 5 (const int)
0:101 Constant:
0:101 Constant:
0:101 4.000000
0:101 4.000000
0:106 Sequence
0:106 move second child to first child (temp float)
0:106 'b' (global float)
0:106 Constant:
0:106 0.000000
0:? Linker Objects
0:? Linker Objects
0:? 'gu' (global implicitly-sized array of float)
0:? 'gu' (global implicitly-sized array of float)
0:? 'g4' (global 4-element array of float)
0:? 'g4' (global 4-element array of float)
...
@@ -267,6 +273,8 @@ ERROR: node is still EOpNull!
...
@@ -267,6 +273,8 @@ ERROR: node is still EOpNull!
0:? 'f' (global float)
0:? 'f' (global float)
0:? 'gUnusedUnsized' (global implicitly-sized array of float)
0:? 'gUnusedUnsized' (global implicitly-sized array of float)
0:? 'i' (global implicitly-sized array of int)
0:? 'i' (global implicitly-sized array of int)
0:? 'emptyA' (global implicitly-sized array of float)
0:? 'b' (global float)
Linked fragment stage:
Linked fragment stage:
...
@@ -503,6 +511,11 @@ ERROR: node is still EOpNull!
...
@@ -503,6 +511,11 @@ ERROR: node is still EOpNull!
0:101 5 (const int)
0:101 5 (const int)
0:101 Constant:
0:101 Constant:
0:101 4.000000
0:101 4.000000
0:106 Sequence
0:106 move second child to first child (temp float)
0:106 'b' (global float)
0:106 Constant:
0:106 0.000000
0:? Linker Objects
0:? Linker Objects
0:? 'gu' (global 4-element array of float)
0:? 'gu' (global 4-element array of float)
0:? 'g4' (global 4-element array of float)
0:? 'g4' (global 4-element array of float)
...
@@ -512,4 +525,6 @@ ERROR: node is still EOpNull!
...
@@ -512,4 +525,6 @@ ERROR: node is still EOpNull!
0:? 'f' (global float)
0:? 'f' (global float)
0:? 'gUnusedUnsized' (global 1-element array of float)
0:? 'gUnusedUnsized' (global 1-element array of float)
0:? 'i' (global 1-element array of int)
0:? 'i' (global 1-element array of int)
0:? 'emptyA' (global 1-element array of float)
0:? 'b' (global float)
glslang/MachineIndependent/ParseHelper.cpp
View file @
12a38337
...
@@ -1947,9 +1947,7 @@ bool TParseContext::constructorError(TSourceLoc loc, TIntermNode* node, TFunctio
...
@@ -1947,9 +1947,7 @@ bool TParseContext::constructorError(TSourceLoc loc, TIntermNode* node, TFunctio
}
}
//
//
// Note: It's okay to have too many components available, but not okay to have unused
// Walk the arguments for first-pass checks and collection of information.
// arguments. 'full' will go to true when enough args have been seen. If we loop
// again, there is an extra argument, so 'overfull' will become true.
//
//
int
size
=
0
;
int
size
=
0
;
...
@@ -1958,19 +1956,32 @@ bool TParseContext::constructorError(TSourceLoc loc, TIntermNode* node, TFunctio
...
@@ -1958,19 +1956,32 @@ bool TParseContext::constructorError(TSourceLoc loc, TIntermNode* node, TFunctio
bool
overFull
=
false
;
bool
overFull
=
false
;
bool
matrixInMatrix
=
false
;
bool
matrixInMatrix
=
false
;
bool
arrayArg
=
false
;
bool
arrayArg
=
false
;
for
(
int
i
=
0
;
i
<
function
.
getParamCount
();
++
i
)
{
for
(
int
arg
=
0
;
arg
<
function
.
getParamCount
();
++
arg
)
{
size
+=
function
[
i
].
type
->
computeNumComponents
();
if
(
function
[
arg
].
type
->
isArray
())
{
if
(
!
function
[
arg
].
type
->
isExplicitlySizedArray
())
{
if
(
constructingMatrix
&&
function
[
i
].
type
->
isMatrix
())
// Can't construct from an unsized array.
error
(
loc
,
"array argument must be sized"
,
"constructor"
,
""
);
return
true
;
}
arrayArg
=
true
;
}
if
(
constructingMatrix
&&
function
[
arg
].
type
->
isMatrix
())
matrixInMatrix
=
true
;
matrixInMatrix
=
true
;
if
(
full
)
// 'full' will go to true when enough args have been seen. If we loop
// again, there is an extra argument.
if
(
full
)
{
// For vectors and matrices, it's okay to have too many components
// available, but not okay to have unused arguments.
overFull
=
true
;
overFull
=
true
;
}
size
+=
function
[
arg
].
type
->
computeNumComponents
();
if
(
op
!=
EOpConstructStruct
&&
!
type
.
isArray
()
&&
size
>=
type
.
computeNumComponents
())
if
(
op
!=
EOpConstructStruct
&&
!
type
.
isArray
()
&&
size
>=
type
.
computeNumComponents
())
full
=
true
;
full
=
true
;
if
(
function
[
i
].
type
->
getQualifier
().
storage
!=
EvqConst
)
if
(
function
[
arg
].
type
->
getQualifier
().
storage
!=
EvqConst
)
constType
=
false
;
constType
=
false
;
if
(
function
[
i
].
type
->
isArray
())
arrayArg
=
true
;
}
}
if
(
constType
)
if
(
constType
)
...
...
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