Skip to content

Commit 151415b

Browse files
committed
[Frontend] Don't enable EmbeddedRestrictions warnings under -suppress-warnings
Fixes #84697.
1 parent 77617c9 commit 151415b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,7 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
26462646

26472647
// If the "embedded" flag was provided, enable the EmbeddedRestrictions
26482648
// warning group. This group is opt-in in non-Embedded builds.
2649-
if (isEmbedded(Args)) {
2649+
if (isEmbedded(Args) && !Args.hasArg(OPT_suppress_warnings)) {
26502650
Opts.WarningsAsErrorsRules.push_back(
26512651
WarningAsErrorRule(WarningAsErrorRule::Action::Disable,
26522652
"EmbeddedRestrictions"));

test/embedded/restrictions.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %target-typecheck-verify-swift -Wwarning EmbeddedRestrictions -verify-additional-prefix nonembedded-
22
// RUN: %target-typecheck-verify-swift -enable-experimental-feature Embedded -verify-additional-prefix embedded-
3-
3+
// RUN: %target-swift-frontend -typecheck %s -suppress-warnings -enable-experimental-feature Embedded -DSUPPRESS_WEAK
44
// REQUIRES: swift_in_compiler
55
// REQUIRES: swift_feature_Embedded
66

@@ -54,12 +54,14 @@ struct SomeStruct {
5454
public class MyClass { }
5555

5656
public struct MyStruct {
57+
#if !SUPPRESS_WEAK
5758
var normalVar: MyClass
5859
weak var weakVar: MyClass? // expected-nonembedded-warning {{attribute 'weak' cannot be used in Embedded Swift}}
5960
// expected-embedded-error@-1 {{attribute 'weak' cannot be used in Embedded Swift}}
6061

6162
unowned var unownedVar: MyClass // expected-nonembedded-warning {{attribute 'unowned' cannot be used in Embedded Swift}}
6263
// expected-embedded-error @-1{{attribute 'unowned' cannot be used in Embedded Swift}}
64+
#endif
6365

6466
unowned(unsafe) var unownedUnsafe: MyClass
6567
}

0 commit comments

Comments
 (0)