Issue an error if a varying lvalue is passed to a reference function parameter.

(Previously, we crashed.)
This commit is contained in:
Matt Pharr
2011-12-03 15:27:54 -08:00
parent 0fd7811344
commit 3efbfc30b7
2 changed files with 12 additions and 1 deletions

View File

@@ -2599,6 +2599,17 @@ FunctionCallExpr::GetValue(FunctionEmitContext *ctx) const {
const Type *paramType = ft->GetParameterType(i);
const Type *argLValueType = argExpr->GetLValueType();
if (argLValueType != NULL &&
dynamic_cast<const PointerType *>(argLValueType) != NULL &&
argLValueType->IsVaryingType() &&
dynamic_cast<const ReferenceType *>(paramType) != NULL) {
Error(argExpr->pos, "Illegal to pass a \"varying\" lvalue to a "
"reference parameter of type \"%s\".",
paramType->GetString().c_str());
return NULL;
}
// Do whatever type conversion is needed
argExpr = TypeConvertExpr(argExpr, paramType,
"function call argument");

View File

@@ -1,4 +1,4 @@
// ffofoof
// Illegal to pass a "varying" lvalue to a reference parameter
void inc(float &x) { ++x; }