[cfe-commits] r91884 - in /cfe/trunk/lib/Sema: Sema.h SemaInit.cpp

Eli Friedman eli.friedman at gmail.com
Mon Dec 21 18:50:30 PST 2009


Author: efriedma
Date: Mon Dec 21 20:50:30 2009
New Revision: 91884

URL: http://llvm.org/viewvc/llvm-project?rev=91884&view=rev
Log:
Zap CheckInitializerTypes.


Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=91884&r1=91883&r2=91884&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Mon Dec 21 20:50:30 2009
@@ -3669,10 +3669,6 @@
                                    SourceLocation CmpLoc);
 
   /// type checking declaration initializers (C99 6.7.8)
-
-  bool CheckInitializerTypes(Expr *&simpleInit_or_initList, QualType &declType,
-                             const InitializedEntity &Entity,
-                             const InitializationKind &Kind);
   bool CheckInitList(const InitializedEntity &Entity,
                      InitListExpr *&InitList, QualType &DeclType);
   bool CheckForConstantInitializer(Expr *e, QualType t);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Dec 21 20:50:30 2009
@@ -134,118 +134,6 @@
   Str->setType(DeclT);
 }
 
-bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
-                                 const InitializedEntity &Entity,
-                                 const InitializationKind &Kind) {
-  SourceLocation InitLoc = Kind.getLocation();
-  DeclarationName InitEntity = Entity.getName();
-  bool DirectInit = (Kind.getKind() == InitializationKind::IK_Direct);
-  
-  if (DeclType->isDependentType() ||
-      Init->isTypeDependent() || Init->isValueDependent()) {
-    // We have either a dependent type or a type- or value-dependent
-    // initializer, so we don't perform any additional checking at
-    // this point.
-
-    // If the declaration is a non-dependent, incomplete array type
-    // that has an initializer, then its type will be completed once
-    // the initializer is instantiated.
-    if (!DeclType->isDependentType()) {
-      if (const IncompleteArrayType *ArrayT
-                           = Context.getAsIncompleteArrayType(DeclType)) {
-        if (InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
-          if (!ILE->isTypeDependent()) {
-            // Compute the constant array type from the length of the 
-            // initializer list. 
-            // FIXME: This will be wrong if there are designated 
-            // initializations. Good thing they don't exist in C++!
-            llvm::APInt NumElements(Context.getTypeSize(Context.getSizeType()),
-                                    ILE->getNumInits());
-            llvm::APInt Zero(Context.getTypeSize(Context.getSizeType()), 0);
-            if (NumElements == Zero) {
-              // Sizing an array implicitly to zero is not allowed by ISO C,
-              // but is supported by GNU.
-              Diag(ILE->getLocStart(), diag::ext_typecheck_zero_array_size);
-            }
-            
-            DeclType = Context.getConstantArrayType(ArrayT->getElementType(),
-                                                    NumElements,
-                                                    ArrayT->getSizeModifier(),
-                                           ArrayT->getIndexTypeCVRQualifiers());
-            return false;
-          }
-        }
-        
-        // Make the array type-dependent by making it dependently-sized.
-        DeclType = Context.getDependentSizedArrayType(ArrayT->getElementType(),
-                                                      /*NumElts=*/0,
-                                                     ArrayT->getSizeModifier(),
-                                           ArrayT->getIndexTypeCVRQualifiers(),
-                                                      SourceRange());
-      }
-    }
-
-    return false;
-  }
-
-  // C++ [dcl.init.ref]p1:
-  //   A variable declared to be a T& or T&&, that is "reference to type T"
-  //   (8.3.2), shall be initialized by an object, or function, of
-  //   type T or by an object that can be converted into a T.
-  if (DeclType->isReferenceType()) {
-    InitializationSequence InitSeq(*this, Entity, Kind, &Init, 1);
-    OwningExprResult CurInit = InitSeq.Perform(*this, Entity, Kind,
-                                         MultiExprArg(*this, (void**)&Init, 1),
-                                               &DeclType);
-    if (CurInit.isInvalid())
-      return true;
-
-    Init = CurInit.takeAs<Expr>();
-    return false;
-  }
-
-  // C99 6.7.8p3: The type of the entity to be initialized shall be an array
-  // of unknown size ("[]") or an object type that is not a variable array type.
-  if (const VariableArrayType *VAT = Context.getAsVariableArrayType(DeclType))
-    return Diag(InitLoc,  diag::err_variable_object_no_init)
-    << VAT->getSizeExpr()->getSourceRange();
-
-  InitListExpr *InitList = dyn_cast<InitListExpr>(Init);
-  if (!InitList) {
-    // FIXME: Handle wide strings
-    if (Expr *Str = IsStringInit(Init, DeclType, Context)) {
-      CheckStringInit(Str, DeclType, *this);
-      return false;
-    }
-
-    // C++ [dcl.init]p14:
-    //   -- If the destination type is a (possibly cv-qualified) class
-    //      type:
-    if (getLangOptions().CPlusPlus && DeclType->isRecordType()) {
-      InitializationSequence InitSeq(*this, Entity, Kind, &Init, 1);
-      OwningExprResult CurInit = InitSeq.Perform(*this, Entity, Kind,
-                                          MultiExprArg(*this, (void**)&Init, 1),
-                                                 &DeclType);
-      if (CurInit.isInvalid())
-        return true;
-
-      Init = CurInit.takeAs<Expr>();
-      return false;
-    }
-
-    // C99 6.7.8p16.
-    if (DeclType->isArrayType())
-      return Diag(Init->getLocStart(), diag::err_array_init_list_required)
-        << Init->getSourceRange();
-
-    return CheckSingleInitializer(Init, DeclType, DirectInit, *this);
-  }
-
-  bool hadError = CheckInitList(Entity, InitList, DeclType);
-  Init = InitList;
-  return hadError;
-}
-
 //===----------------------------------------------------------------------===//
 // Semantic checking for initializer lists.
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list