Skip to content

Commit fcd206f

Browse files
committed
[Strict memory safety] Squash warning about unsafety in "@objc enum" synthesized code
There's a synthesized call to unsafeBitCast(_:to:), which is obvious unsafe, and is being diagnosed as such. The compiler generates this call, so have the compiler also generate the `unsafe` around it to suppress these warnings. Fixes rdar://151199011.
1 parent 2dacde1 commit fcd206f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/Sema/DerivedConformance/DerivedConformanceRawRepresentable.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ deriveBodyRawRepresentable_raw(AbstractFunctionDecl *toRawDecl, void *) {
105105

106106
auto *argList = ArgumentList::forImplicitCallTo(functionRef->getName(),
107107
{selfRef, typeExpr}, C);
108-
auto call = CallExpr::createImplicit(C, functionRef, argList);
108+
Expr *call = CallExpr::createImplicit(C, functionRef, argList);
109+
if (C.LangOpts.hasFeature(Feature::StrictMemorySafety))
110+
call = UnsafeExpr::createImplicit(C, SourceLoc(), call);
109111
auto *returnStmt = ReturnStmt::createImplicit(C, call);
110112
auto body = BraceStmt::create(C, SourceLoc(), ASTNode(returnStmt),
111113
SourceLoc());

0 commit comments

Comments
 (0)