]> granicus.if.org Git - clang/commitdiff
Fix a few isObjectTypes that really need to be isIncompleteOrObject
authorDouglas Gregor <dgregor@apple.com>
Tue, 24 Mar 2009 20:13:58 +0000 (20:13 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 24 Mar 2009 20:13:58 +0000 (20:13 +0000)
types; add another use of RequireCompleteType.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67644 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaNamedCast.cpp
lib/Sema/SemaTemplate.cpp

index 03d8501245205fec9eed702ee4f270340bf71494..d2972caff7d8ce6d0db93765d7c0bc1061cebb7d 100644 (file)
@@ -3752,9 +3752,7 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *Op, SourceLocation OpLoc,
     // OK!
   } else if (const PointerType *PT = ResType->getAsPointerType()) {
     // C99 6.5.2.4p2, 6.5.6p2
-    if (PT->getPointeeType()->isObjectType()) {
-      // Pointer to object is ok!
-    } else if (PT->getPointeeType()->isVoidType()) {
+    if (PT->getPointeeType()->isVoidType()) {
       if (getLangOptions().CPlusPlus) {
         Diag(OpLoc, diag::err_typecheck_pointer_arith_void_type)
           << Op->getSourceRange();
@@ -3772,13 +3770,11 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *Op, SourceLocation OpLoc,
 
       Diag(OpLoc, diag::ext_gnu_ptr_func_arith)
         << ResType << Op->getSourceRange();
-    } else {
-      RequireCompleteType(OpLoc, PT->getPointeeType(),
-                             diag::err_typecheck_arithmetic_incomplete_type,
-                             Op->getSourceRange(), SourceRange(),
-                             ResType);
+    } else if (RequireCompleteType(OpLoc, PT->getPointeeType(),
+                               diag::err_typecheck_arithmetic_incomplete_type,
+                                   Op->getSourceRange(), SourceRange(),
+                                   ResType))
       return QualType();
-    }
   } else if (ResType->isComplexType()) {
     // C99 does not support ++/-- on complex types, we allow as an extension.
     Diag(OpLoc, diag::ext_integer_increment_complex)
index e2cda9dff9293084eb82656564bfd8457a0902b1..a6cb24ceecfcb9f2330ed7bae0c69683fcbf3286 100644 (file)
@@ -613,13 +613,14 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
         << Type << Ex->getSourceRange());
 
     QualType Pointee = Type->getAsPointerType()->getPointeeType();
-    if (!Pointee->isVoidType() &&
-        RequireCompleteType(StartLoc, Pointee, diag::warn_delete_incomplete,
-                               Ex->getSourceRange()))
-      return ExprError();
-    else if (!Pointee->isObjectType())
+    if (Pointee->isFunctionType() || Pointee->isVoidType())
       return ExprError(Diag(StartLoc, diag::err_delete_operand)
         << Type << Ex->getSourceRange());
+    else if (!Pointee->isDependentType() &&
+             RequireCompleteType(StartLoc, Pointee, 
+                                 diag::warn_delete_incomplete,
+                                 Ex->getSourceRange()))
+      return ExprError();
 
     // FIXME: Look up the correct operator delete overload and pass a pointer
     // along.
index 96de1bbad0b1c7d332d6e0865d7d332d09692ef5..8c45fe627864ae8cf5b64cab5fdea772e6da6543 100644 (file)
@@ -520,7 +520,7 @@ CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
     if (SrcPointee->isVoidType()) {
       if (const PointerType *DestPointer = DestType->getAsPointerType()) {
         QualType DestPointee = DestPointer->getPointeeType();
-        if (DestPointee->isObjectType()) {
+        if (DestPointee->isIncompleteOrObjectType()) {
           // This is definitely the intended conversion, but it might fail due
           // to a const violation.
           if (!DestPointee.isAtLeastAsQualifiedAs(SrcPointee)) {
index fd39a9150f983097cf93f04a22d1b6dceda48d69..c7899d1ecc534ea9cbbd9d7643512fc8d040176d 100644 (file)
@@ -1395,7 +1395,8 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
     //   -- for a non-type template-parameter of type pointer to
     //      object, qualification conversions (4.4) and the
     //      array-to-pointer conversion (4.2) are applied.
-    assert(ParamType->getAsPointerType()->getPointeeType()->isObjectType() &&
+    assert(ParamType->getAsPointerType()->getPointeeType()
+             ->isIncompleteOrObjectType() &&
            "Only object pointers allowed here");
 
     if (ArgType->isArrayType()) {
@@ -1434,7 +1435,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
     //      identical) type of the template-argument. The
     //      template-parameter is bound directly to the
     //      template-argument, which must be an lvalue.
-    assert(ParamRefType->getPointeeType()->isObjectType() &&
+    assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
            "Only object references allowed here");
 
     if (!Context.hasSameUnqualifiedType(ParamRefType->getPointeeType(), ArgType)) {