Issue an error if a varying lvalue is passed to a reference function parameter.
(Previously, we crashed.)
This commit is contained in:
11
expr.cpp
11
expr.cpp
@@ -2599,6 +2599,17 @@ FunctionCallExpr::GetValue(FunctionEmitContext *ctx) const {
|
|||||||
|
|
||||||
const Type *paramType = ft->GetParameterType(i);
|
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
|
// Do whatever type conversion is needed
|
||||||
argExpr = TypeConvertExpr(argExpr, paramType,
|
argExpr = TypeConvertExpr(argExpr, paramType,
|
||||||
"function call argument");
|
"function call argument");
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// ffofoof
|
// Illegal to pass a "varying" lvalue to a reference parameter
|
||||||
|
|
||||||
void inc(float &x) { ++x; }
|
void inc(float &x) { ++x; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user