Submitted by:
Reviewed by:
- Implement FIXME in Sema::CheckIndirectionOperand().
- Added "const" to FunctionDecl::getResultType().

llvm-svn: 39512
This commit is contained in:
Steve Naroff 2007-05-28 16:15:57 +00:00
parent 010015a11e
commit 758ada12f4
3 changed files with 24 additions and 7 deletions

View File

@ -1000,11 +1000,24 @@ QualType Sema::CheckIndirectionOperand(Expr *op, SourceLocation OpLoc) {
assert(!qType.isNull() && "no type for * expression");
// FIXME: need to check if the pointee is an incomplete type. Find spec ref.
if (PointerType *PT = dyn_cast<PointerType>(qType.getCanonicalType()))
return PT->getPointeeType();
Diag(OpLoc, diag::err_typecheck_indirection_expr, qType.getAsString(),
op->getSourceRange());
if (PointerType *PT = dyn_cast<PointerType>(qType.getCanonicalType())) {
QualType ptype = PT->getPointeeType();
// C99 6.5.3.2p4. "if it points to an object,...".
if (ptype->isIncompleteType()) { // An incomplete type is not an object
// GCC compat: special case 'void *' (treat as warning).
if (ptype->isVoidType()) {
Diag(OpLoc, diag::ext_typecheck_deref_ptr_to_void,
qType.getAsString(), op->getSourceRange());
} else {
Diag(OpLoc, diag::err_typecheck_deref_incomplete_type,
ptype.getAsString(), op->getSourceRange());
return QualType();
}
}
return ptype;
}
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer,
qType.getAsString(), op->getSourceRange());
return QualType();
}

View File

@ -210,7 +210,7 @@ public:
}
void setParams(VarDecl **NewParamInfo, unsigned NumParams);
QualType getResultType() {
QualType getResultType() const {
return cast<FunctionType>(getType())->getResultType();
}
StorageClass getStorageClass() const { return SClass; }

View File

@ -550,8 +550,12 @@ DIAG(err_typecheck_invalid_lvalue_addrof, ERROR,
"invalid lvalue in address expression")
DIAG(err_typecheck_unary_expr, ERROR,
"invalid argument type to unary expression '%0'")
DIAG(err_typecheck_indirection_expr, ERROR,
DIAG(err_typecheck_indirection_requires_pointer, ERROR,
"indirection requires a pointer operand ('%0' invalid)")
DIAG(err_typecheck_deref_incomplete_type, ERROR,
"dereferencing pointer to incomplete type '%0'")
DIAG(ext_typecheck_deref_ptr_to_void, EXTENSION,
"dereferencing '%0' pointer")
DIAG(err_typecheck_invalid_operands, ERROR,
"invalid operands to binary expression ('%0' and '%1')")
DIAG(ext_typecheck_comparison_of_pointer_integer, EXTENSION,