diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 67748923d9ef7..7305f0edb8d3d 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -2646,7 +2646,7 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args, // If the "embedded" flag was provided, enable the EmbeddedRestrictions // warning group. This group is opt-in in non-Embedded builds. - if (isEmbedded(Args)) { + if (isEmbedded(Args) && !Args.hasArg(OPT_suppress_warnings)) { Opts.WarningsAsErrorsRules.push_back( WarningAsErrorRule(WarningAsErrorRule::Action::Disable, "EmbeddedRestrictions")); diff --git a/test/embedded/restrictions.swift b/test/embedded/restrictions.swift index e2324a2c2898d..4d00ff92a435e 100644 --- a/test/embedded/restrictions.swift +++ b/test/embedded/restrictions.swift @@ -1,6 +1,6 @@ // RUN: %target-typecheck-verify-swift -Wwarning EmbeddedRestrictions -verify-additional-prefix nonembedded- // RUN: %target-typecheck-verify-swift -enable-experimental-feature Embedded -verify-additional-prefix embedded- - +// RUN: %target-swift-frontend -typecheck %s -suppress-warnings -enable-experimental-feature Embedded -DSUPPRESS_WEAK // REQUIRES: swift_in_compiler // REQUIRES: swift_feature_Embedded @@ -54,12 +54,14 @@ struct SomeStruct { public class MyClass { } public struct MyStruct { + #if !SUPPRESS_WEAK var normalVar: MyClass weak var weakVar: MyClass? // expected-nonembedded-warning {{attribute 'weak' cannot be used in Embedded Swift}} // expected-embedded-error@-1 {{attribute 'weak' cannot be used in Embedded Swift}} unowned var unownedVar: MyClass // expected-nonembedded-warning {{attribute 'unowned' cannot be used in Embedded Swift}} // expected-embedded-error @-1{{attribute 'unowned' cannot be used in Embedded Swift}} + #endif unowned(unsafe) var unownedUnsafe: MyClass }