HLSL: Fix a grammar error related to constructors in parenthetical expressions
This commit is contained in:
parent
ff13213547
commit
5964c64b2a
7 changed files with 212 additions and 34 deletions
|
|
@ -1718,27 +1718,29 @@ bool HlslGrammar::acceptUnaryExpression(TIntermTyped*& node)
|
|||
if (acceptTokenClass(EHTokLeftParen)) {
|
||||
TType castType;
|
||||
if (acceptType(castType)) {
|
||||
if (! acceptTokenClass(EHTokRightParen)) {
|
||||
expected(")");
|
||||
return false;
|
||||
if (acceptTokenClass(EHTokRightParen)) {
|
||||
// We've matched "(type)" now, get the expression to cast
|
||||
TSourceLoc loc = token.loc;
|
||||
if (! acceptUnaryExpression(node))
|
||||
return false;
|
||||
|
||||
// Hook it up like a constructor
|
||||
TFunction* constructorFunction = parseContext.handleConstructorCall(loc, castType);
|
||||
if (constructorFunction == nullptr) {
|
||||
expected("type that can be constructed");
|
||||
return false;
|
||||
}
|
||||
TIntermTyped* arguments = nullptr;
|
||||
parseContext.handleFunctionArgument(constructorFunction, arguments, node);
|
||||
node = parseContext.handleFunctionCall(loc, constructorFunction, arguments);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
// This could be a parenthesized constructor, ala (int(3)), and we just accepted
|
||||
// the '(int' part. We must back up twice.
|
||||
recedeToken();
|
||||
recedeToken();
|
||||
}
|
||||
|
||||
// We've matched "(type)" now, get the expression to cast
|
||||
TSourceLoc loc = token.loc;
|
||||
if (! acceptUnaryExpression(node))
|
||||
return false;
|
||||
|
||||
// Hook it up like a constructor
|
||||
TFunction* constructorFunction = parseContext.handleConstructorCall(loc, castType);
|
||||
if (constructorFunction == nullptr) {
|
||||
expected("type that can be constructed");
|
||||
return false;
|
||||
}
|
||||
TIntermTyped* arguments = nullptr;
|
||||
parseContext.handleFunctionArgument(constructorFunction, arguments, node);
|
||||
node = parseContext.handleFunctionCall(loc, constructorFunction, arguments);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
// This isn't a type cast, but it still started "(", so if it is a
|
||||
// unary expression, it can only be a postfix_expression, so try that.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue