Skip to content

Commit e720de2

Browse files
committed
[Type checker] Protect against an extension having no nominal declaration.
Couldn't come up with a test case, but this should fix the crash in rdar://problem/46817639.
1 parent a8fb416 commit e720de2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,13 @@ void AttributeChecker::visitAccessControlAttr(AccessControlAttr *attr) {
16001600
}
16011601

16021602
NominalTypeDecl *nominal = extension->getExtendedNominal();
1603+
1604+
// Extension is ill-formed; suppress the attribute.
1605+
if (!nominal) {
1606+
attr->setInvalid();
1607+
return;
1608+
}
1609+
16031610
AccessLevel typeAccess = nominal->getFormalAccess();
16041611
if (attr->getAccess() > typeAccess) {
16051612
TC.diagnose(attr->getLocation(), diag::access_control_extension_more,

0 commit comments

Comments
 (0)