Sema::CheckAdditionOperands(): Use Type::getPointeeType() and remove PTy and OPT variables.

llvm-svn: 75505
This commit is contained in:
Steve Naroff 2009-07-13 21:20:41 +00:00
parent 450f266095
commit aacd4cce73
1 changed files with 12 additions and 15 deletions

View File

@ -3831,15 +3831,8 @@ inline QualType Sema::CheckAdditionOperands( // C99 6.5.6
PExp->getType()->isObjCObjectPointerType()) {
if (IExp->getType()->isIntegerType()) {
QualType PointeeTy;
const PointerType *PTy = NULL;
const ObjCObjectPointerType *OPT = NULL;
QualType PointeeTy = PExp->getType()->getPointeeType();
if ((PTy = PExp->getType()->getAsPointerType()))
PointeeTy = PTy->getPointeeType();
else if ((OPT = PExp->getType()->getAsObjCObjectPointerType()))
PointeeTy = OPT->getPointeeType();
// Check for arithmetic on pointers to incomplete types.
if (PointeeTy->isVoidType()) {
if (getLangOptions().CPlusPlus) {
@ -3861,13 +3854,17 @@ inline QualType Sema::CheckAdditionOperands( // C99 6.5.6
// GNU extension: arithmetic on pointer to function
Diag(Loc, diag::ext_gnu_ptr_func_arith)
<< lex->getType() << lex->getSourceRange();
} else if (((PTy && !PTy->isDependentType()) || OPT) &&
RequireCompleteType(Loc, PointeeTy,
diag::err_typecheck_arithmetic_incomplete_type,
PExp->getSourceRange(), SourceRange(),
PExp->getType()))
return QualType();
} else {
// Check if we require a complete type.
if (((PExp->getType()->isPointerType() &&
!PExp->getType()->getAsPointerType()->isDependentType()) ||
PExp->getType()->isObjCObjectPointerType()) &&
RequireCompleteType(Loc, PointeeTy,
diag::err_typecheck_arithmetic_incomplete_type,
PExp->getSourceRange(), SourceRange(),
PExp->getType()))
return QualType();
}
// Diagnose bad cases where we step over interface counts.
if (PointeeTy->isObjCInterfaceType() && LangOpts.ObjCNonFragileABI) {
Diag(Loc, diag::err_arithmetic_nonfragile_interface)