Commit 085b8334 by John Kessenich

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

This also makes it match how GLSL handles the same thing.
parent bf9a2f30
......@@ -18,6 +18,25 @@ void Test1()
struct mystruct2 { float a; float b; float c; };
mystruct2 test5 = { {8,}, {9,}, {10}, };
const mystruct2 constTest5 = { {8,}, {9,}, {10}, };
constTest5.c;
const float step = 1.f;
float n = 0;
const float3 a[8] = {
normalize(float3(1, 1, 1)) * (n += step),
normalize(float3(-1, -1, -1)) * (n += step),
normalize(float3(-1, -1, 1)) * (n += step),
normalize(float3(-1, 1, -1)) * (n += step),
normalize(float3(-1, 1, 1)) * (n += step),
normalize(float3(1, -1, -1)) * (n += step),
normalize(float3(1, -1, 1)) * (n += step),
normalize(float3(1, 1, -1)) * (n += step) };
const struct one { float3 a; } oneNonConst = { normalize(float3(-1, 1, 1)) * (n += step) };
const struct two { float3 a;
float3 b; } twoNonConst = { normalize(float3(-1, 1, 1)) * (n += step),
normalize(float3(-1, 1, 1)) * (n += step) };
}
struct PS_OUTPUT { float4 color : SV_Target0; };
......
......@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.1730"
#define GLSLANG_DATE "03-Jan-2017"
#define GLSLANG_REVISION "Overload400-PrecQual.1739"
#define GLSLANG_DATE "05-Jan-2017"
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment