diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-12-22 02:50:30 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-12-22 02:50:30 +0000 |
commit | bba48cbd77ff5168b32efa9b77845d45f9205e48 (patch) | |
tree | 6ddbcc7304a31681b756135ec3f7d333de0e4369 /lib/Sema/SemaInit.cpp | |
parent | 4a2c19bf2330e31851330423187ec48035cab1a5 (diff) |
Zap CheckInitializerTypes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91884 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index cc22e7458a..80cfc3637e 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -134,118 +134,6 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, Sema &S) { 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. //===----------------------------------------------------------------------===// |