Skip to content

Commit 9efa442

Browse files
committed
---
yaml --- r: 349063 b: refs/heads/master c: a7b0a4c h: refs/heads/master i: 349061: 01e8895 349059: 782b620 349055: 3148ab8
1 parent 55a0f85 commit 9efa442

File tree

2 files changed

+23
-46
lines changed

2 files changed

+23
-46
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3062b8c64a97e6941c5b3ed43cd3b7892250d8fb
2+
refs/heads/master: a7b0a4c7a96035b5e2f94ee8ab174a551b83eb89
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/Sema/TypeCheckDecl.cpp

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3249,6 +3249,20 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
32493249
FD->getFullName());
32503250
}
32513251
}
3252+
3253+
// If the function is exported to C, it must be representable in (Obj-)C.
3254+
// FIXME: This needs to be moved to its own request if we want to
3255+
// productize @_cdecl.
3256+
if (auto CDeclAttr = FD->getAttrs().getAttribute<swift::CDeclAttr>()) {
3257+
Optional<ForeignErrorConvention> errorConvention;
3258+
if (isRepresentableInObjC(FD, ObjCReason::ExplicitlyCDecl,
3259+
errorConvention)) {
3260+
if (FD->hasThrows()) {
3261+
FD->setForeignErrorConvention(*errorConvention);
3262+
TC.diagnose(CDeclAttr->getLocation(), diag::cdecl_throws);
3263+
}
3264+
}
3265+
}
32523266
}
32533267

32543268
void visitModuleDecl(ModuleDecl *) { }
@@ -4108,10 +4122,6 @@ static void validateParameterType(ParamDecl *decl) {
41084122
}
41094123

41104124
void TypeChecker::validateDecl(ValueDecl *D) {
4111-
// Generic parameters are validated as part of their context.
4112-
if (isa<GenericTypeParamDecl>(D))
4113-
return;
4114-
41154125
// Handling validation failure due to re-entrancy is left
41164126
// up to the caller, who must call hasInterfaceType() to
41174127
// check that validateDecl() returned a fully-formed decl.
@@ -4139,13 +4149,11 @@ void TypeChecker::validateDecl(ValueDecl *D) {
41394149
case DeclKind::IfConfig:
41404150
case DeclKind::PoundDiagnostic:
41414151
case DeclKind::MissingMember:
4142-
llvm_unreachable("not a value decl");
4143-
41444152
case DeclKind::Module:
4145-
return;
4146-
4153+
case DeclKind::OpaqueType:
41474154
case DeclKind::GenericTypeParam:
4148-
llvm_unreachable("handled above");
4155+
llvm_unreachable("should not get here");
4156+
return;
41494157

41504158
case DeclKind::AssociatedType: {
41514159
auto assocType = cast<AssociatedTypeDecl>(D);
@@ -4158,9 +4166,6 @@ void TypeChecker::validateDecl(ValueDecl *D) {
41584166
typeAlias->computeType();
41594167
break;
41604168
}
4161-
4162-
case DeclKind::OpaqueType:
4163-
break;
41644169

41654170
case DeclKind::Enum:
41664171
case DeclKind::Struct:
@@ -4254,40 +4259,12 @@ void TypeChecker::validateDecl(ValueDecl *D) {
42544259
}
42554260

42564261
case DeclKind::Func:
4257-
case DeclKind::Accessor: {
4258-
auto *FD = cast<FuncDecl>(D);
4259-
4260-
DeclValidationRAII IBV(FD);
4261-
4262-
// FIXME: Roll all of this interface type computation into a request.
4263-
FD->computeType();
4264-
4265-
// If the function is exported to C, it must be representable in (Obj-)C.
4266-
if (auto CDeclAttr = FD->getAttrs().getAttribute<swift::CDeclAttr>()) {
4267-
Optional<ForeignErrorConvention> errorConvention;
4268-
if (isRepresentableInObjC(FD, ObjCReason::ExplicitlyCDecl,
4269-
errorConvention)) {
4270-
if (FD->hasThrows()) {
4271-
FD->setForeignErrorConvention(*errorConvention);
4272-
diagnose(CDeclAttr->getLocation(), diag::cdecl_throws);
4273-
}
4274-
}
4275-
}
4276-
4277-
break;
4278-
}
4279-
4280-
case DeclKind::Constructor: {
4281-
auto *CD = cast<ConstructorDecl>(D);
4282-
DeclValidationRAII IBV(CD);
4283-
CD->computeType();
4284-
break;
4285-
}
4286-
4262+
case DeclKind::Accessor:
4263+
case DeclKind::Constructor:
42874264
case DeclKind::Destructor: {
4288-
auto *DD = cast<DestructorDecl>(D);
4289-
DeclValidationRAII IBV(DD);
4290-
DD->computeType();
4265+
auto *AFD = cast<AbstractFunctionDecl>(D);
4266+
DeclValidationRAII IBV(AFD);
4267+
AFD->computeType();
42914268
break;
42924269
}
42934270

0 commit comments

Comments
 (0)