TFunction realFunc(&name, function->getType());
+ // Use copyParam to avoid shared ownership of the 'type' field
+ // of the parameter.
for (int i = 0; i < function->getParamCount(); ++i) {
- realFunc.addParameter((*function)[i]);
+ realFunc.addParameter(TParameter().copyParam((*function)[i]));
}
TParameter tmpP = { 0, &uintType };
- realFunc.addParameter(tmpP);
+ realFunc.addParameter(TParameter().copyParam(tmpP));
arguments = intermediate.growAggregate(arguments, intermediate.addConstantUnion(1, loc, true));
result = handleFunctionCall(loc, &realFunc, arguments);
TFunction realFunc(&name, function->getType());
for (int i = 0; i < function->getParamCount(); ++i) {
- realFunc.addParameter((*function)[i]);
+ realFunc.addParameter(TParameter().copyParam((*function)[i]));
}
TParameter tmpP = { 0, &uintType };
- realFunc.addParameter(tmpP);
+ realFunc.addParameter(TParameter().copyParam(tmpP));
arguments = intermediate.growAggregate(arguments, intermediate.addConstantUnion(-1, loc, true));
result = handleFunctionCall(loc, &realFunc, arguments);
TString *name;
TType* type;
TIntermTyped* defaultValue;
- void copyParam(const TParameter& param)
+ TParameter& copyParam(const TParameter& param)
{
if (param.name)
name = NewPoolTString(param.name->c_str());
name = 0;
type = param.type->clone();
defaultValue = param.defaultValue;
+ return *this;
}
TBuiltInVariable getDeclaredBuiltIn() const { return type->getQualifier().declaredBuiltIn; }
};