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
bb79abcc
Commit
bb79abcc
authored
Oct 07, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Validate implicit initializer assignment to opaque members.
Fixes #1091.
parent
07ed11f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
hlslGrammar.cpp
hlsl/hlslGrammar.cpp
+6
-3
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+11
-1
No files found.
hlsl/hlslGrammar.cpp
View file @
bb79abcc
...
@@ -2426,6 +2426,9 @@ bool HlslGrammar::acceptDefaultParameterDeclaration(const TType& type, TIntermTy
...
@@ -2426,6 +2426,9 @@ bool HlslGrammar::acceptDefaultParameterDeclaration(const TType& type, TIntermTy
node
=
parseContext
.
handleFunctionCall
(
token
.
loc
,
constructor
,
node
);
node
=
parseContext
.
handleFunctionCall
(
token
.
loc
,
constructor
,
node
);
}
}
if
(
node
==
nullptr
)
return
false
;
// If this is simply a constant, we can use it directly.
// If this is simply a constant, we can use it directly.
if
(
node
->
getAsConstantUnion
())
if
(
node
->
getAsConstantUnion
())
return
true
;
return
true
;
...
@@ -2862,7 +2865,7 @@ bool HlslGrammar::acceptUnaryExpression(TIntermTyped*& node)
...
@@ -2862,7 +2865,7 @@ bool HlslGrammar::acceptUnaryExpression(TIntermTyped*& node)
parseContext
.
handleFunctionArgument
(
constructorFunction
,
arguments
,
node
);
parseContext
.
handleFunctionArgument
(
constructorFunction
,
arguments
,
node
);
node
=
parseContext
.
handleFunctionCall
(
loc
,
constructorFunction
,
arguments
);
node
=
parseContext
.
handleFunctionCall
(
loc
,
constructorFunction
,
arguments
);
return
true
;
return
node
!=
nullptr
;
}
else
{
}
else
{
// This could be a parenthesized constructor, ala (int(3)), and we just accepted
// This could be a parenthesized constructor, ala (int(3)), and we just accepted
// the '(int' part. We must back up twice.
// the '(int' part. We must back up twice.
...
@@ -3072,7 +3075,7 @@ bool HlslGrammar::acceptConstructor(TIntermTyped*& node)
...
@@ -3072,7 +3075,7 @@ bool HlslGrammar::acceptConstructor(TIntermTyped*& node)
// hook it up
// hook it up
node
=
parseContext
.
handleFunctionCall
(
arguments
->
getLoc
(),
constructorFunction
,
arguments
);
node
=
parseContext
.
handleFunctionCall
(
arguments
->
getLoc
(),
constructorFunction
,
arguments
);
return
true
;
return
node
!=
nullptr
;
}
}
return
false
;
return
false
;
...
@@ -3120,7 +3123,7 @@ bool HlslGrammar::acceptFunctionCall(const TSourceLoc& loc, TString& name, TInte
...
@@ -3120,7 +3123,7 @@ bool HlslGrammar::acceptFunctionCall(const TSourceLoc& loc, TString& name, TInte
// call
// call
node
=
parseContext
.
handleFunctionCall
(
loc
,
function
,
arguments
);
node
=
parseContext
.
handleFunctionCall
(
loc
,
function
,
arguments
);
return
true
;
return
node
!=
nullptr
;
}
}
// arguments
// arguments
...
...
hlsl/hlslParseHelper.cpp
View file @
bb79abcc
...
@@ -4981,8 +4981,10 @@ TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunct
...
@@ -4981,8 +4981,10 @@ TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunct
// It's a constructor, of type 'type'.
// It's a constructor, of type 'type'.
//
//
result
=
handleConstructor
(
loc
,
arguments
,
type
);
result
=
handleConstructor
(
loc
,
arguments
,
type
);
if
(
result
==
nullptr
)
if
(
result
==
nullptr
)
{
error
(
loc
,
"cannot construct with these arguments"
,
type
.
getCompleteString
().
c_str
(),
""
);
error
(
loc
,
"cannot construct with these arguments"
,
type
.
getCompleteString
().
c_str
(),
""
);
return
nullptr
;
}
}
}
}
else
{
}
else
{
//
//
...
@@ -7736,6 +7738,14 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
...
@@ -7736,6 +7738,14 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
return
addConstructor
(
loc
,
initList
,
arrayType
);
return
addConstructor
(
loc
,
initList
,
arrayType
);
}
else
if
(
type
.
isStruct
())
{
}
else
if
(
type
.
isStruct
())
{
// do we have implicit assignments to opaques?
for
(
size_t
i
=
initList
->
getSequence
().
size
();
i
<
type
.
getStruct
()
->
size
();
++
i
)
{
if
((
*
type
.
getStruct
())[
i
].
type
->
containsOpaque
())
{
error
(
loc
,
"cannot implicitly initialize opaque members"
,
"initializer list"
,
""
);
return
nullptr
;
}
}
// lengthen list to be long enough
// lengthen list to be long enough
lengthenList
(
loc
,
initList
->
getSequence
(),
static_cast
<
int
>
(
type
.
getStruct
()
->
size
()),
scalarInit
);
lengthenList
(
loc
,
initList
->
getSequence
(),
static_cast
<
int
>
(
type
.
getStruct
()
->
size
()),
scalarInit
);
...
...
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