Skip to content

Commit 25f12c9

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 091462a commit 25f12c9

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
@@ -1992,6 +1992,8 @@ getStableSelfAccessKind(swift::SelfAccessKind MM) {
19921992
# define DECL(KIND, PARENT)\
19931993
LLVM_ATTRIBUTE_UNUSED \
19941994
static void verifyAttrSerializable(const KIND ## Decl *D) {\
1995+
if (D->Decl::getASTContext().LangOpts.AllowModuleWithCompilerErrors)\
1996+
return;\
19951997
for (auto Attr : D->getAttrs()) {\
19961998
assert(Attr->canAppearOnDecl(D) && "attribute cannot appear on a " #KIND);\
19971999
}\
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)