зеркало из https://github.com/microsoft/clang-1.git
Rename DiagnoseIncompleteType to RequireCompleteType, and update the documentation to reflect the fact that we can instantiate templates here
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66421 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
ff8d204dcf
Коммит
86447ec25f
|
@ -283,7 +283,7 @@ public:
|
||||||
|
|
||||||
virtual TypeResult ActOnTypeName(Scope *S, Declarator &D);
|
virtual TypeResult ActOnTypeName(Scope *S, Declarator &D);
|
||||||
|
|
||||||
bool DiagnoseIncompleteType(SourceLocation Loc, QualType T, unsigned diag,
|
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag,
|
||||||
SourceRange Range1 = SourceRange(),
|
SourceRange Range1 = SourceRange(),
|
||||||
SourceRange Range2 = SourceRange(),
|
SourceRange Range2 = SourceRange(),
|
||||||
QualType PrintType = QualType());
|
QualType PrintType = QualType());
|
||||||
|
|
|
@ -893,7 +893,7 @@ bool Sema::CheckParmsForFunctionDef(FunctionDecl *FD) {
|
||||||
// function declarator that is part of a function definition of
|
// function declarator that is part of a function definition of
|
||||||
// that function shall not have incomplete type.
|
// that function shall not have incomplete type.
|
||||||
if (!Param->isInvalidDecl() &&
|
if (!Param->isInvalidDecl() &&
|
||||||
DiagnoseIncompleteType(Param->getLocation(), Param->getType(),
|
RequireCompleteType(Param->getLocation(), Param->getType(),
|
||||||
diag::err_typecheck_decl_incomplete_type)) {
|
diag::err_typecheck_decl_incomplete_type)) {
|
||||||
Param->setInvalidDecl();
|
Param->setInvalidDecl();
|
||||||
HasInvalidParm = true;
|
HasInvalidParm = true;
|
||||||
|
@ -2255,7 +2255,7 @@ void Sema::ActOnUninitializedDecl(DeclTy *dcl) {
|
||||||
Var->getStorageClass() != VarDecl::PrivateExtern &&
|
Var->getStorageClass() != VarDecl::PrivateExtern &&
|
||||||
InitType->isRecordType()) {
|
InitType->isRecordType()) {
|
||||||
const CXXConstructorDecl *Constructor = 0;
|
const CXXConstructorDecl *Constructor = 0;
|
||||||
if (!DiagnoseIncompleteType(Var->getLocation(), InitType,
|
if (!RequireCompleteType(Var->getLocation(), InitType,
|
||||||
diag::err_invalid_incomplete_type_use))
|
diag::err_invalid_incomplete_type_use))
|
||||||
Constructor
|
Constructor
|
||||||
= PerformInitializationByConstructor(InitType, 0, 0,
|
= PerformInitializationByConstructor(InitType, 0, 0,
|
||||||
|
@ -2333,7 +2333,7 @@ Sema::DeclTy *Sema::FinalizeDeclaratorGroup(Scope *S, DeclTy *group) {
|
||||||
if (IDecl->isBlockVarDecl() &&
|
if (IDecl->isBlockVarDecl() &&
|
||||||
IDecl->getStorageClass() != VarDecl::Extern) {
|
IDecl->getStorageClass() != VarDecl::Extern) {
|
||||||
if (!IDecl->isInvalidDecl() &&
|
if (!IDecl->isInvalidDecl() &&
|
||||||
DiagnoseIncompleteType(IDecl->getLocation(), T,
|
RequireCompleteType(IDecl->getLocation(), T,
|
||||||
diag::err_typecheck_decl_incomplete_type))
|
diag::err_typecheck_decl_incomplete_type))
|
||||||
IDecl->setInvalidDecl();
|
IDecl->setInvalidDecl();
|
||||||
}
|
}
|
||||||
|
@ -2347,7 +2347,7 @@ Sema::DeclTy *Sema::FinalizeDeclaratorGroup(Scope *S, DeclTy *group) {
|
||||||
// C99 6.9.2 (p2, p5): Implicit initialization causes an incomplete
|
// C99 6.9.2 (p2, p5): Implicit initialization causes an incomplete
|
||||||
// array to be completed. Don't issue a diagnostic.
|
// array to be completed. Don't issue a diagnostic.
|
||||||
} else if (!IDecl->isInvalidDecl() &&
|
} else if (!IDecl->isInvalidDecl() &&
|
||||||
DiagnoseIncompleteType(IDecl->getLocation(), T,
|
RequireCompleteType(IDecl->getLocation(), T,
|
||||||
diag::err_typecheck_decl_incomplete_type))
|
diag::err_typecheck_decl_incomplete_type))
|
||||||
// C99 6.9.2p3: If the declaration of an identifier for an object is
|
// C99 6.9.2p3: If the declaration of an identifier for an object is
|
||||||
// a tentative definition and has internal linkage (C99 6.2.2p3), the
|
// a tentative definition and has internal linkage (C99 6.2.2p3), the
|
||||||
|
@ -3488,7 +3488,7 @@ void Sema::ActOnFields(Scope* S,
|
||||||
// C99 6.7.2.1p2 - A field may not be an incomplete type except...
|
// C99 6.7.2.1p2 - A field may not be an incomplete type except...
|
||||||
if (FDTy->isIncompleteType()) {
|
if (FDTy->isIncompleteType()) {
|
||||||
if (!Record) { // Incomplete ivar type is always an error.
|
if (!Record) { // Incomplete ivar type is always an error.
|
||||||
DiagnoseIncompleteType(FD->getLocation(), FD->getType(),
|
RequireCompleteType(FD->getLocation(), FD->getType(),
|
||||||
diag::err_field_incomplete);
|
diag::err_field_incomplete);
|
||||||
FD->setInvalidDecl();
|
FD->setInvalidDecl();
|
||||||
EnclosingDecl->setInvalidDecl();
|
EnclosingDecl->setInvalidDecl();
|
||||||
|
@ -3497,7 +3497,7 @@ void Sema::ActOnFields(Scope* S,
|
||||||
if (i != NumFields-1 || // ... that the last member ...
|
if (i != NumFields-1 || // ... that the last member ...
|
||||||
!Record->isStruct() || // ... of a structure ...
|
!Record->isStruct() || // ... of a structure ...
|
||||||
!FDTy->isArrayType()) { //... may have incomplete array type.
|
!FDTy->isArrayType()) { //... may have incomplete array type.
|
||||||
DiagnoseIncompleteType(FD->getLocation(), FD->getType(),
|
RequireCompleteType(FD->getLocation(), FD->getType(),
|
||||||
diag::err_field_incomplete);
|
diag::err_field_incomplete);
|
||||||
FD->setInvalidDecl();
|
FD->setInvalidDecl();
|
||||||
EnclosingDecl->setInvalidDecl();
|
EnclosingDecl->setInvalidDecl();
|
||||||
|
|
|
@ -350,7 +350,7 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
|
||||||
// C++ [class.derived]p2:
|
// C++ [class.derived]p2:
|
||||||
// The class-name in a base-specifier shall not be an incompletely
|
// The class-name in a base-specifier shall not be an incompletely
|
||||||
// defined class.
|
// defined class.
|
||||||
if (DiagnoseIncompleteType(BaseLoc, BaseType, diag::err_incomplete_base_class,
|
if (RequireCompleteType(BaseLoc, BaseType, diag::err_incomplete_base_class,
|
||||||
SpecifierRange))
|
SpecifierRange))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -2270,7 +2270,7 @@ Sema::DeclTy *Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D)
|
||||||
DK = diag::err_catch_incomplete_ref;
|
DK = diag::err_catch_incomplete_ref;
|
||||||
}
|
}
|
||||||
if ((Mode == 0 || !BaseType->isVoidType()) &&
|
if ((Mode == 0 || !BaseType->isVoidType()) &&
|
||||||
DiagnoseIncompleteType(Begin, BaseType, DK))
|
RequireCompleteType(Begin, BaseType, DK))
|
||||||
Invalid = true;
|
Invalid = true;
|
||||||
|
|
||||||
// FIXME: Need to test for ability to copy-construct and destroy the
|
// FIXME: Need to test for ability to copy-construct and destroy the
|
||||||
|
|
|
@ -1189,7 +1189,7 @@ bool Sema::CheckSizeOfAlignOfOperand(QualType exprType,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DiagnoseIncompleteType(OpLoc, exprType,
|
return RequireCompleteType(OpLoc, exprType,
|
||||||
isSizeof ? diag::err_sizeof_incomplete_type :
|
isSizeof ? diag::err_sizeof_incomplete_type :
|
||||||
diag::err_alignof_incomplete_type,
|
diag::err_alignof_incomplete_type,
|
||||||
ExprRange);
|
ExprRange);
|
||||||
|
@ -1703,7 +1703,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
|
||||||
// of the ObjC 'id' struct.
|
// of the ObjC 'id' struct.
|
||||||
if (const RecordType *RTy = BaseType->getAsRecordType()) {
|
if (const RecordType *RTy = BaseType->getAsRecordType()) {
|
||||||
RecordDecl *RDecl = RTy->getDecl();
|
RecordDecl *RDecl = RTy->getDecl();
|
||||||
if (DiagnoseIncompleteType(OpLoc, BaseType,
|
if (RequireCompleteType(OpLoc, BaseType,
|
||||||
diag::err_typecheck_incomplete_tag,
|
diag::err_typecheck_incomplete_tag,
|
||||||
BaseExpr->getSourceRange()))
|
BaseExpr->getSourceRange()))
|
||||||
return ExprError();
|
return ExprError();
|
||||||
|
@ -2257,7 +2257,7 @@ Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
|
||||||
if (literalType->isVariableArrayType())
|
if (literalType->isVariableArrayType())
|
||||||
return ExprError(Diag(LParenLoc, diag::err_variable_object_no_init)
|
return ExprError(Diag(LParenLoc, diag::err_variable_object_no_init)
|
||||||
<< SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd()));
|
<< SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd()));
|
||||||
} else if (DiagnoseIncompleteType(LParenLoc, literalType,
|
} else if (RequireCompleteType(LParenLoc, literalType,
|
||||||
diag::err_typecheck_decl_incomplete_type,
|
diag::err_typecheck_decl_incomplete_type,
|
||||||
SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd())))
|
SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd())))
|
||||||
return ExprError();
|
return ExprError();
|
||||||
|
@ -3017,7 +3017,7 @@ inline QualType Sema::CheckAdditionOperands( // C99 6.5.6
|
||||||
Diag(Loc, diag::ext_gnu_ptr_func_arith)
|
Diag(Loc, diag::ext_gnu_ptr_func_arith)
|
||||||
<< lex->getType() << lex->getSourceRange();
|
<< lex->getType() << lex->getSourceRange();
|
||||||
} else {
|
} else {
|
||||||
DiagnoseIncompleteType(Loc, PTy->getPointeeType(),
|
RequireCompleteType(Loc, PTy->getPointeeType(),
|
||||||
diag::err_typecheck_arithmetic_incomplete_type,
|
diag::err_typecheck_arithmetic_incomplete_type,
|
||||||
lex->getSourceRange(), SourceRange(),
|
lex->getSourceRange(), SourceRange(),
|
||||||
lex->getType());
|
lex->getType());
|
||||||
|
@ -3436,7 +3436,7 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
|
||||||
break;
|
break;
|
||||||
case Expr::MLV_IncompleteType:
|
case Expr::MLV_IncompleteType:
|
||||||
case Expr::MLV_IncompleteVoidType:
|
case Expr::MLV_IncompleteVoidType:
|
||||||
return S.DiagnoseIncompleteType(Loc, E->getType(),
|
return S.RequireCompleteType(Loc, E->getType(),
|
||||||
diag::err_typecheck_incomplete_type_not_modifiable_lvalue,
|
diag::err_typecheck_incomplete_type_not_modifiable_lvalue,
|
||||||
E->getSourceRange());
|
E->getSourceRange());
|
||||||
case Expr::MLV_DuplicateVectorComponents:
|
case Expr::MLV_DuplicateVectorComponents:
|
||||||
|
@ -3577,7 +3577,7 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *Op, SourceLocation OpLoc,
|
||||||
Diag(OpLoc, diag::ext_gnu_ptr_func_arith)
|
Diag(OpLoc, diag::ext_gnu_ptr_func_arith)
|
||||||
<< ResType << Op->getSourceRange();
|
<< ResType << Op->getSourceRange();
|
||||||
} else {
|
} else {
|
||||||
DiagnoseIncompleteType(OpLoc, PT->getPointeeType(),
|
RequireCompleteType(OpLoc, PT->getPointeeType(),
|
||||||
diag::err_typecheck_arithmetic_incomplete_type,
|
diag::err_typecheck_arithmetic_incomplete_type,
|
||||||
Op->getSourceRange(), SourceRange(),
|
Op->getSourceRange(), SourceRange(),
|
||||||
ResType);
|
ResType);
|
||||||
|
|
|
@ -177,7 +177,7 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
|
||||||
if (Ty->isArrayType())
|
if (Ty->isArrayType())
|
||||||
return Diag(TyBeginLoc, diag::err_value_init_for_array_type) << FullRange;
|
return Diag(TyBeginLoc, diag::err_value_init_for_array_type) << FullRange;
|
||||||
if (!Ty->isDependentType() && !Ty->isVoidType() &&
|
if (!Ty->isDependentType() && !Ty->isVoidType() &&
|
||||||
DiagnoseIncompleteType(TyBeginLoc, Ty,
|
RequireCompleteType(TyBeginLoc, Ty,
|
||||||
diag::err_invalid_incomplete_type_use, FullRange))
|
diag::err_invalid_incomplete_type_use, FullRange))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -595,7 +595,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
|
||||||
|
|
||||||
QualType Pointee = Type->getAsPointerType()->getPointeeType();
|
QualType Pointee = Type->getAsPointerType()->getPointeeType();
|
||||||
if (!Pointee->isVoidType() &&
|
if (!Pointee->isVoidType() &&
|
||||||
DiagnoseIncompleteType(StartLoc, Pointee, diag::warn_delete_incomplete,
|
RequireCompleteType(StartLoc, Pointee, diag::warn_delete_incomplete,
|
||||||
Ex->getSourceRange()))
|
Ex->getSourceRange()))
|
||||||
return true;
|
return true;
|
||||||
else if (!Pointee->isObjectType()) {
|
else if (!Pointee->isObjectType()) {
|
||||||
|
|
|
@ -776,7 +776,7 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
|
||||||
if (DestPointee->isVoidType()) {
|
if (DestPointee->isVoidType()) {
|
||||||
assert(DestPointer && "Reference to void is not possible");
|
assert(DestPointer && "Reference to void is not possible");
|
||||||
} else if (DestRecord) {
|
} else if (DestRecord) {
|
||||||
if (Self.DiagnoseIncompleteType(OpRange.getBegin(), DestPointee,
|
if (Self.RequireCompleteType(OpRange.getBegin(), DestPointee,
|
||||||
diag::err_bad_dynamic_cast_incomplete,
|
diag::err_bad_dynamic_cast_incomplete,
|
||||||
DestRange))
|
DestRange))
|
||||||
return;
|
return;
|
||||||
|
@ -810,7 +810,7 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
|
||||||
|
|
||||||
const RecordType *SrcRecord = SrcPointee->getAsRecordType();
|
const RecordType *SrcRecord = SrcPointee->getAsRecordType();
|
||||||
if (SrcRecord) {
|
if (SrcRecord) {
|
||||||
if (Self.DiagnoseIncompleteType(OpRange.getBegin(), SrcPointee,
|
if (Self.RequireCompleteType(OpRange.getBegin(), SrcPointee,
|
||||||
diag::err_bad_dynamic_cast_incomplete,
|
diag::err_bad_dynamic_cast_incomplete,
|
||||||
SrcExpr->getSourceRange()))
|
SrcExpr->getSourceRange()))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -395,7 +395,7 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
|
||||||
SourceLocation Loc, DeclarationName Entity) {
|
SourceLocation Loc, DeclarationName Entity) {
|
||||||
// C99 6.7.5.2p1: If the element type is an incomplete or function type,
|
// C99 6.7.5.2p1: If the element type is an incomplete or function type,
|
||||||
// reject it (e.g. void ary[7], struct foo ary[7], void ary[7]())
|
// reject it (e.g. void ary[7], struct foo ary[7], void ary[7]())
|
||||||
if (DiagnoseIncompleteType(Loc, T,
|
if (RequireCompleteType(Loc, T,
|
||||||
diag::err_illegal_decl_array_incomplete_type))
|
diag::err_illegal_decl_array_incomplete_type))
|
||||||
return QualType();
|
return QualType();
|
||||||
|
|
||||||
|
@ -992,13 +992,15 @@ void Sema::ProcessTypeAttributeList(QualType &Result, const AttributeList *AL) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief If the type T is incomplete and cannot be completed,
|
/// @brief Ensure that the type T is a complete type.
|
||||||
/// produce a suitable diagnostic.
|
|
||||||
///
|
///
|
||||||
/// This routine checks whether the type @p T is complete in any
|
/// This routine checks whether the type @p T is complete in any
|
||||||
/// context where a complete type is required. If @p T is a complete
|
/// context where a complete type is required. If @p T is a complete
|
||||||
/// type, returns false. If @p T is incomplete, issues the diagnostic
|
/// type, returns false. If @p T is a class template specialization,
|
||||||
/// @p diag (giving it the type @p T) and returns true.
|
/// this routine then attempts to perform class template
|
||||||
|
/// instantiation. If instantiation fails, or if @p T is incomplete
|
||||||
|
/// and cannot be completed, issues the diagnostic @p diag (giving it
|
||||||
|
/// the type @p T) and returns true.
|
||||||
///
|
///
|
||||||
/// @param Loc The location in the source that the incomplete type
|
/// @param Loc The location in the source that the incomplete type
|
||||||
/// diagnostic should refer to.
|
/// diagnostic should refer to.
|
||||||
|
@ -1023,11 +1025,7 @@ void Sema::ProcessTypeAttributeList(QualType &Result, const AttributeList *AL) {
|
||||||
///
|
///
|
||||||
/// @returns @c true if @p T is incomplete and a diagnostic was emitted,
|
/// @returns @c true if @p T is incomplete and a diagnostic was emitted,
|
||||||
/// @c false otherwise.
|
/// @c false otherwise.
|
||||||
///
|
bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag,
|
||||||
/// @todo When Clang gets proper support for C++ templates, this
|
|
||||||
/// routine will also be able perform template instantiation when @p T
|
|
||||||
/// is a class template specialization.
|
|
||||||
bool Sema::DiagnoseIncompleteType(SourceLocation Loc, QualType T, unsigned diag,
|
|
||||||
SourceRange Range1, SourceRange Range2,
|
SourceRange Range1, SourceRange Range2,
|
||||||
QualType PrintType) {
|
QualType PrintType) {
|
||||||
// If we have a complete type, we're done.
|
// If we have a complete type, we're done.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче