HLSL: Fix issue #658: Don't adopt initializer constness from declaration.

This also makes it match how GLSL handles the same thing.
This commit is contained in:
John Kessenich
2017-01-05 10:28:26 -07:00
parent bf9a2f30c9
commit 085b833490
4 changed files with 417 additions and 69 deletions

View File

@@ -5256,8 +5256,16 @@ TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TInterm
// constructor-style subtree, allowing the rest of the code to operate
// identically for both kinds of initializers.
//
//
// Type can't be deduced from the initializer list, so a skeletal type to
// follow has to be passed in. Constness and specialization-constness
// should be deduced bottom up, not dictated by the skeletal type.
//
TType skeletalType;
skeletalType.shallowCopy(variable->getType());
skeletalType.getQualifier().makeTemporary();
if (initializer->getAsAggregate() && initializer->getAsAggregate()->getOp() == EOpNull)
initializer = convertInitializerList(loc, variable->getType(), initializer);
initializer = convertInitializerList(loc, skeletalType, initializer);
if (! initializer) {
// error recovery; don't leave const without constant values
if (qualifier == EvqConst)
@@ -5458,8 +5466,9 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
emulatedConstructorArguments = initList->getSequence()[0];
else
emulatedConstructorArguments = initList;
TIntermTyped* constructor = addConstructor(loc, emulatedConstructorArguments, type);
return addConstructor(loc, emulatedConstructorArguments, type);
return constructor;
}
// Lengthen list to be long enough to cover any gap from the current list size