Skip to content

Commit 073a582

Browse files
committed
[Serialization] Skip verifying attributes when allowing errors
When allowing errors any attribute could be on any decl, so don't verify whether an attribute can appear on a decl. Note that these attributes aren't serialized anyway since they'll be set to invalid during typechecking and hence skipped.
1 parent 7856f2d commit 073a582

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/Serialization/Serialization.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,8 @@ getStableSelfAccessKind(swift::SelfAccessKind MM) {
20122012
# define DECL(KIND, PARENT)\
20132013
LLVM_ATTRIBUTE_UNUSED \
20142014
static void verifyAttrSerializable(const KIND ## Decl *D) {\
2015+
if (D->Decl::getASTContext().LangOpts.AllowModuleWithCompilerErrors)\
2016+
return;\
20152017
for (auto Attr : D->getAttrs()) {\
20162018
assert(Attr->canAppearOnDecl(D) && "attribute cannot appear on a " #KIND);\
20172019
}\
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-swift-frontend -module-name errors -emit-module -o %t/errors.swiftmodule -experimental-allow-module-with-compiler-errors %s
4+
5+
// @discardableResult is not allowed on a struct, make sure we don't crash
6+
// when allowing errors
7+
8+
@discardableResult
9+
struct SomeStruct {}

0 commit comments

Comments
 (0)