[cfe-commits] r67644 - in /cfe/trunk/lib/Sema: SemaExpr.cpp SemaExprCXX.cpp SemaNamedCast.cpp SemaTemplate.cpp

Douglas Gregor dgregor at apple.com
Tue Mar 24 13:13:59 PDT 2009


Author: dgregor
Date: Tue Mar 24 15:13:58 2009
New Revision: 67644

URL: http://llvm.org/viewvc/llvm-project?rev=67644&view=rev
Log:
Fix a few isObjectTypes that really need to be isIncompleteOrObject
types; add another use of RequireCompleteType.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaNamedCast.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=67644&r1=67643&r2=67644&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Mar 24 15:13:58 2009
@@ -3752,9 +3752,7 @@
     // 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 @@
 
       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)

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=67644&r1=67643&r2=67644&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Mar 24 15:13:58 2009
@@ -613,13 +613,14 @@
         << 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.

Modified: cfe/trunk/lib/Sema/SemaNamedCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaNamedCast.cpp?rev=67644&r1=67643&r2=67644&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaNamedCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaNamedCast.cpp Tue Mar 24 15:13:58 2009
@@ -520,7 +520,7 @@
     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)) {

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=67644&r1=67643&r2=67644&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Mar 24 15:13:58 2009
@@ -1395,7 +1395,8 @@
     //   -- 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 @@
     //      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)) {





More information about the cfe-commits mailing list