diff --git a/expr.cpp b/expr.cpp index e67cb814..f4c84055 100644 --- a/expr.cpp +++ b/expr.cpp @@ -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(argLValueType) != NULL && + argLValueType->IsVaryingType() && + dynamic_cast(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"); diff --git a/tests_errors/varying-lvalue-to-ref.ispc b/tests_errors/varying-lvalue-to-ref.ispc index 0944de6e..e6ffc54d 100644 --- a/tests_errors/varying-lvalue-to-ref.ispc +++ b/tests_errors/varying-lvalue-to-ref.ispc @@ -1,4 +1,4 @@ -// ffofoof +// Illegal to pass a "varying" lvalue to a reference parameter void inc(float &x) { ++x; }