HLSL: allow trailing commas in initializer lists & scalar initialization
This commit is contained in:
@@ -1549,8 +1549,11 @@ bool HlslGrammar::acceptInitializer(TIntermTyped*& node)
|
||||
node = intermediate.growAggregate(node, expr, loc);
|
||||
|
||||
// COMMA
|
||||
if (acceptTokenClass(EHTokComma))
|
||||
if (acceptTokenClass(EHTokComma)) {
|
||||
if (acceptTokenClass(EHTokRightBrace)) // allow trailing comma
|
||||
return true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// RIGHT_BRACE
|
||||
if (acceptTokenClass(EHTokRightBrace))
|
||||
|
||||
@@ -3727,7 +3727,12 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
|
||||
error(loc, "wrong vector size (or rows in a matrix column):", "initializer list", type.getCompleteString().c_str());
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
} else if (type.isScalar()) {
|
||||
if ((int)initList->getSequence().size() != 1) {
|
||||
error(loc, "scalar expected one element:", "initializer list", type.getCompleteString().c_str());
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
error(loc, "unexpected initializer-list type:", "initializer list", type.getCompleteString().c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user