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
f2cfe270
Commit
f2cfe270
authored
Jul 19, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue #388.
Protect more against error recovery of bad built-in variable redeclarations.
parent
31a51bec
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
10 deletions
+14
-10
120.vert
Test/120.vert
+2
-0
120.vert.out
Test/baseResults/120.vert.out
+5
-4
ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.cpp
+7
-6
No files found.
Test/120.vert
View file @
f2cfe270
...
...
@@ -192,6 +192,8 @@ void foo213()
gl_ClipDistance
[
1
]
=
0
.
3
;
// ERROR
}
int
gl_ModelViewMatrix
[]
=
0
;
// token pasting (ERRORS...)
#define mac abc##def
...
...
Test/baseResults/120.vert.out
View file @
f2cfe270
...
...
@@ -75,10 +75,11 @@ ERROR: 0:191: '=' : cannot convert from 'temp float' to 'temp int'
ERROR: 0:192: 'gl_ClipDistance' : undeclared identifier
ERROR: 0:192: 'gl_ClipDistance' : left of '[' is not of type array, matrix, or vector
ERROR: 0:192: 'assign' : l-value required (can't modify a const)
ERROR: 0:198: 'token pasting (##)' : not supported for this version or the enabled extensions
ERROR: 0:198: '##' : token pasting not implemented (internal error)
ERROR: 0:198: '' : syntax error
ERROR: 79 compilation errors. No code generated.
ERROR: 0:195: 'gl_ModelViewMatrix' : identifiers starting with "gl_" are reserved
ERROR: 0:200: 'token pasting (##)' : not supported for this version or the enabled extensions
ERROR: 0:200: '##' : token pasting not implemented (internal error)
ERROR: 0:200: '' : syntax error
ERROR: 80 compilation errors. No code generated.
Shader version: 120
...
...
glslang/MachineIndependent/ParseHelper.cpp
View file @
f2cfe270
...
...
@@ -3175,12 +3175,13 @@ void TParseContext::arrayDimMerge(TType& type, const TArraySizes* sizes)
//
void
TParseContext
::
declareArray
(
const
TSourceLoc
&
loc
,
TString
&
identifier
,
const
TType
&
type
,
TSymbol
*&
symbol
,
bool
&
newDeclaration
)
{
if
(
!
symbol
)
{
if
(
symbol
==
nullptr
)
{
bool
currentScope
;
symbol
=
symbolTable
.
find
(
identifier
,
nullptr
,
&
currentScope
);
if
(
symbol
&&
builtInName
(
identifier
)
&&
!
symbolTable
.
atBuiltInLevel
())
{
// bad shader (errors already reported) trying to redeclare a built-in name as an array
symbol
=
nullptr
;
return
;
}
if
(
symbol
==
nullptr
||
!
currentScope
)
{
...
...
@@ -3213,7 +3214,7 @@ void TParseContext::declareArray(const TSourceLoc& loc, TString& identifier, con
// Process a redeclaration.
//
if
(
!
symbol
)
{
if
(
symbol
==
nullptr
)
{
error
(
loc
,
"array variable name expected"
,
identifier
.
c_str
(),
""
);
return
;
}
...
...
@@ -4934,7 +4935,7 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
// Check for redeclaration of built-ins and/or attempting to declare a reserved name
bool
newDeclaration
=
false
;
// true if a new entry gets added to the symbol table
TSymbol
*
symbol
=
redeclareBuiltinVariable
(
loc
,
identifier
,
type
.
getQualifier
(),
publicType
.
shaderQualifiers
,
newDeclaration
);
if
(
!
symbol
)
if
(
symbol
==
nullptr
)
reservedErrorCheck
(
loc
,
identifier
);
inheritGlobalDefaults
(
type
.
getQualifier
());
...
...
@@ -4959,18 +4960,18 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
}
}
else
{
// non-array case
if
(
!
symbol
)
if
(
symbol
==
nullptr
)
symbol
=
declareNonArray
(
loc
,
identifier
,
type
,
newDeclaration
);
else
if
(
type
!=
symbol
->
getType
())
error
(
loc
,
"cannot change the type of"
,
"redeclaration"
,
symbol
->
getName
().
c_str
());
}
if
(
!
symbol
)
if
(
symbol
==
nullptr
)
return
nullptr
;
// Deal with initializer
TIntermNode
*
initNode
=
nullptr
;
if
(
symbol
&&
initializer
)
{
if
(
symbol
!=
nullptr
&&
initializer
)
{
TVariable
*
variable
=
symbol
->
getAsVariable
();
if
(
!
variable
)
{
error
(
loc
,
"initializer requires a variable, not a member"
,
identifier
.
c_str
(),
""
);
...
...
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