mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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.
This commit is contained in:
@@ -2012,6 +2012,8 @@ getStableSelfAccessKind(swift::SelfAccessKind MM) {
|
|||||||
# define DECL(KIND, PARENT)\
|
# define DECL(KIND, PARENT)\
|
||||||
LLVM_ATTRIBUTE_UNUSED \
|
LLVM_ATTRIBUTE_UNUSED \
|
||||||
static void verifyAttrSerializable(const KIND ## Decl *D) {\
|
static void verifyAttrSerializable(const KIND ## Decl *D) {\
|
||||||
|
if (D->Decl::getASTContext().LangOpts.AllowModuleWithCompilerErrors)\
|
||||||
|
return;\
|
||||||
for (auto Attr : D->getAttrs()) {\
|
for (auto Attr : D->getAttrs()) {\
|
||||||
assert(Attr->canAppearOnDecl(D) && "attribute cannot appear on a " #KIND);\
|
assert(Attr->canAppearOnDecl(D) && "attribute cannot appear on a " #KIND);\
|
||||||
}\
|
}\
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
|
||||||
|
// RUN: %target-swift-frontend -module-name errors -emit-module -o %t/errors.swiftmodule -experimental-allow-module-with-compiler-errors %s
|
||||||
|
|
||||||
|
// @discardableResult is not allowed on a struct, make sure we don't crash
|
||||||
|
// when allowing errors
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
struct SomeStruct {}
|
||||||
Reference in New Issue
Block a user