Small improvements to error location reporting, assertions in expr.cpp
This commit is contained in:
21
expr.cpp
21
expr.cpp
@@ -2409,7 +2409,7 @@ BinaryExpr::Print() const {
|
|||||||
static const char *
|
static const char *
|
||||||
lOpString(AssignExpr::Op op) {
|
lOpString(AssignExpr::Op op) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case AssignExpr::Assign: return "=";
|
case AssignExpr::Assign: return "assignment operator";
|
||||||
case AssignExpr::MulAssign: return "*=";
|
case AssignExpr::MulAssign: return "*=";
|
||||||
case AssignExpr::DivAssign: return "/=";
|
case AssignExpr::DivAssign: return "/=";
|
||||||
case AssignExpr::ModAssign: return "%%=";
|
case AssignExpr::ModAssign: return "%%=";
|
||||||
@@ -2629,7 +2629,7 @@ AssignExpr::TypeCheck() {
|
|||||||
const FunctionType *ftype;
|
const FunctionType *ftype;
|
||||||
if (dynamic_cast<const PointerType *>(lvalueType) == NULL ||
|
if (dynamic_cast<const PointerType *>(lvalueType) == NULL ||
|
||||||
(ftype = dynamic_cast<const FunctionType *>(lvalueType->GetBaseType())) == NULL) {
|
(ftype = dynamic_cast<const FunctionType *>(lvalueType->GetBaseType())) == NULL) {
|
||||||
Error(pos, "Can't assign function pointer to type \"%s\".",
|
Error(lvalue->pos, "Can't assign function pointer to type \"%s\".",
|
||||||
lvalue->GetType()->GetString().c_str());
|
lvalue->GetType()->GetString().c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -2674,13 +2674,13 @@ AssignExpr::TypeCheck() {
|
|||||||
else if (op == Assign)
|
else if (op == Assign)
|
||||||
rvalue = TypeConvertExpr(rvalue, lhsType, "assignment");
|
rvalue = TypeConvertExpr(rvalue, lhsType, "assignment");
|
||||||
else {
|
else {
|
||||||
Error(pos, "Assignment operator \"%s\" is illegal with pointer types.",
|
Error(lvalue->pos, "Assignment operator \"%s\" is illegal with pointer types.",
|
||||||
lOpString(op));
|
lOpString(op));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<const ArrayType *>(lhsType) != NULL) {
|
else if (dynamic_cast<const ArrayType *>(lhsType) != NULL) {
|
||||||
Error(pos, "Illegal to assign to array type \"%s\".",
|
Error(lvalue->pos, "Illegal to assign to array type \"%s\".",
|
||||||
lhsType->GetString().c_str());
|
lhsType->GetString().c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -3922,8 +3922,10 @@ IndexExpr::TypeCheck() {
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
const Type *baseExprType = baseExpr->GetType();
|
const Type *baseExprType = baseExpr->GetType();
|
||||||
if (baseExprType == NULL)
|
if (baseExprType == NULL) {
|
||||||
|
Assert(m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!dynamic_cast<const SequentialType *>(baseExprType->GetReferenceTarget()) &&
|
if (!dynamic_cast<const SequentialType *>(baseExprType->GetReferenceTarget()) &&
|
||||||
!dynamic_cast<const PointerType *>(baseExprType)) {
|
!dynamic_cast<const PointerType *>(baseExprType)) {
|
||||||
@@ -4212,8 +4214,10 @@ VectorMemberExpr::GetLValue(FunctionEmitContext* ctx) const {
|
|||||||
const Type *
|
const Type *
|
||||||
VectorMemberExpr::GetLValueType() const {
|
VectorMemberExpr::GetLValueType() const {
|
||||||
if (identifier.length() == 1) {
|
if (identifier.length() == 1) {
|
||||||
if (expr == NULL)
|
if (expr == NULL) {
|
||||||
|
Assert(m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
const Type *exprLValueType = dereferenceExpr ? expr->GetType() :
|
const Type *exprLValueType = dereferenceExpr ? expr->GetType() :
|
||||||
expr->GetLValueType();
|
expr->GetLValueType();
|
||||||
@@ -4228,7 +4232,7 @@ VectorMemberExpr::GetLValueType() const {
|
|||||||
Assert(vt != NULL);
|
Assert(vt != NULL);
|
||||||
|
|
||||||
// we don't want to report that it's e.g. a pointer to a float<1>,
|
// we don't want to report that it's e.g. a pointer to a float<1>,
|
||||||
// but ta pointer to a float, etc.
|
// but a pointer to a float, etc.
|
||||||
const Type *elementType = vt->GetElementType();
|
const Type *elementType = vt->GetElementType();
|
||||||
if (dynamic_cast<const ReferenceType *>(exprLValueType) != NULL)
|
if (dynamic_cast<const ReferenceType *>(exprLValueType) != NULL)
|
||||||
return new ReferenceType(elementType);
|
return new ReferenceType(elementType);
|
||||||
@@ -5348,7 +5352,8 @@ ConstExpr::GetConstant(const Type *type) const {
|
|||||||
return llvm::Constant::getNullValue(llvmType);
|
return llvm::Constant::getNullValue(llvmType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FATAL("unexpected type in ConstExpr::GetConstant()");
|
Debug(pos, "Unable to handle type \"%s\" in ConstExpr::GetConstant().",
|
||||||
|
type->GetString().c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user