SemaInit.cpp (199482) | SemaInit.cpp (199990) |
---|---|
1//===--- SemaInit.cpp - Semantic Analysis for Initializers ----------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 122 unchanged lines hidden (view full) --- 131 // then this will set the string literal's type to char[1]. 132 Str->setType(DeclT); 133} 134 135bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType, 136 SourceLocation InitLoc, 137 DeclarationName InitEntity, bool DirectInit) { 138 if (DeclType->isDependentType() || | 1//===--- SemaInit.cpp - Semantic Analysis for Initializers ----------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 122 unchanged lines hidden (view full) --- 131 // then this will set the string literal's type to char[1]. 132 Str->setType(DeclT); 133} 134 135bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType, 136 SourceLocation InitLoc, 137 DeclarationName InitEntity, bool DirectInit) { 138 if (DeclType->isDependentType() || |
139 Init->isTypeDependent() || Init->isValueDependent()) | 139 Init->isTypeDependent() || Init->isValueDependent()) { 140 // We have either a dependent type or a type- or value-dependent 141 // initializer, so we don't perform any additional checking at 142 // this point. 143 144 // If the declaration is a non-dependent, incomplete array type 145 // that has an initializer, then its type will be completed once 146 // the initializer is instantiated. 147 if (!DeclType->isDependentType()) { 148 if (const IncompleteArrayType *ArrayT 149 = Context.getAsIncompleteArrayType(DeclType)) { 150 if (InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) { 151 if (!ILE->isTypeDependent()) { 152 // Compute the constant array type from the length of the 153 // initializer list. 154 // FIXME: This will be wrong if there are designated 155 // initializations. Good thing they don't exist in C++! 156 llvm::APInt NumElements(Context.getTypeSize(Context.getSizeType()), 157 ILE->getNumInits()); 158 llvm::APInt Zero(Context.getTypeSize(Context.getSizeType()), 0); 159 if (NumElements == Zero) { 160 // Sizing an array implicitly to zero is not allowed by ISO C, 161 // but is supported by GNU. 162 Diag(ILE->getLocStart(), diag::ext_typecheck_zero_array_size); 163 } 164 165 DeclType = Context.getConstantArrayType(ArrayT->getElementType(), 166 NumElements, 167 ArrayT->getSizeModifier(), 168 ArrayT->getIndexTypeCVRQualifiers()); 169 return false; 170 } 171 } 172 173 // Make the array type-dependent by making it dependently-sized. 174 DeclType = Context.getDependentSizedArrayType(ArrayT->getElementType(), 175 /*NumElts=*/0, 176 ArrayT->getSizeModifier(), 177 ArrayT->getIndexTypeCVRQualifiers(), 178 SourceRange()); 179 } 180 } 181 |
140 return false; | 182 return false; |
183 } |
|
141 142 // C++ [dcl.init.ref]p1: 143 // A variable declared to be a T& or T&&, that is "reference to type T" 144 // (8.3.2), shall be initialized by an object, or function, of 145 // type T or by an object that can be converted into a T. 146 if (DeclType->isReferenceType()) 147 return CheckReferenceInit(Init, DeclType, InitLoc, 148 /*SuppressUserConversions=*/false, --- 1719 unchanged lines hidden --- | 184 185 // C++ [dcl.init.ref]p1: 186 // A variable declared to be a T& or T&&, that is "reference to type T" 187 // (8.3.2), shall be initialized by an object, or function, of 188 // type T or by an object that can be converted into a T. 189 if (DeclType->isReferenceType()) 190 return CheckReferenceInit(Init, DeclType, InitLoc, 191 /*SuppressUserConversions=*/false, --- 1719 unchanged lines hidden --- |