зеркало из https://github.com/microsoft/clang-1.git
Deducation and instantiation of block types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73232 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
53454dc2c9
Коммит
859ba504e7
|
@ -433,6 +433,21 @@ static bool DeduceTemplateArguments(ASTContext &Context, QualType Param,
|
|||
Deduced);
|
||||
}
|
||||
|
||||
// type(^)(T)
|
||||
// T(^)()
|
||||
// T(^)(T)
|
||||
case Type::BlockPointer: {
|
||||
const BlockPointerType *BlockPtrParam = cast<BlockPointerType>(Param);
|
||||
const BlockPointerType *BlockPtrArg = dyn_cast<BlockPointerType>(Arg);
|
||||
|
||||
if (!BlockPtrArg)
|
||||
return false;
|
||||
|
||||
return DeduceTemplateArguments(Context,
|
||||
BlockPtrParam->getPointeeType(),
|
||||
BlockPtrArg->getPointeeType(), Deduced);
|
||||
}
|
||||
|
||||
case Type::TypeOfExpr:
|
||||
case Type::TypeOf:
|
||||
case Type::Typename:
|
||||
|
|
|
@ -274,9 +274,13 @@ TemplateTypeInstantiator::InstantiatePointerType(const PointerType *T,
|
|||
QualType
|
||||
TemplateTypeInstantiator::InstantiateBlockPointerType(const BlockPointerType *T,
|
||||
unsigned Quals) const {
|
||||
// FIXME: Implement this
|
||||
assert(false && "Cannot instantiate BlockPointerType yet");
|
||||
return QualType();
|
||||
QualType PointeeType = Instantiate(T->getPointeeType());
|
||||
if (PointeeType.isNull())
|
||||
return QualType();
|
||||
|
||||
QualType BlockTy = SemaRef.Context.getBlockPointerType(PointeeType);
|
||||
|
||||
return BlockTy.getQualifiedType(Quals);
|
||||
}
|
||||
|
||||
QualType
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
// RUN: clang-cc -fsyntax-only -verify %s -fblocks
|
||||
template<typename T>
|
||||
struct is_unary_block {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<typename T, typename U>
|
||||
struct is_unary_block<T (^)(U)> {
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
int is_unary_block0[is_unary_block<int>::value ? -1 : 1];
|
||||
int is_unary_block1[is_unary_block<int (^)()>::value ? -1 : 1];
|
||||
int is_unary_block2[is_unary_block<int (^)(int, bool)>::value ? -1 : 1];
|
||||
int is_unary_block3[is_unary_block<int (^)(bool)>::value ? 1 : -1];
|
||||
int is_unary_block4[is_unary_block<int (^)(int)>::value ? 1 : -1];
|
||||
|
||||
template<typename T>
|
||||
struct is_unary_block_with_same_return_type_as_argument_type {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct is_unary_block_with_same_return_type_as_argument_type<T (^)(T)> {
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
int is_unary_block5[is_unary_block_with_same_return_type_as_argument_type<int>::value ? -1 : 1];
|
||||
int is_unary_block6[is_unary_block_with_same_return_type_as_argument_type<int (^)()>::value ? -1 : 1];
|
||||
int is_unary_block7[is_unary_block_with_same_return_type_as_argument_type<int (^)(int, bool)>::value ? -1 : 1];
|
||||
int is_unary_block8[is_unary_block_with_same_return_type_as_argument_type<int (^)(bool)>::value ? -1 : 1];
|
||||
int is_unary_block9[is_unary_block_with_same_return_type_as_argument_type<int (^)(int)>::value ? 1 : -1];
|
||||
int is_unary_block10[is_unary_block_with_same_return_type_as_argument_type<int (^)(int, ...)>::value ? -1 : 1];
|
||||
int is_unary_block11[is_unary_block_with_same_return_type_as_argument_type<int (^ const)(int)>::value ? -1 : 1];
|
Загрузка…
Ссылка в новой задаче