File tree Expand file tree Collapse file tree 3 files changed +4
-7
lines changed Expand file tree Collapse file tree 3 files changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -1853,8 +1853,8 @@ static bool isTypeLevelDeclForAvailabilityFixit(const Decl *D) {
1853
1853
1854
1854
bool IsModuleScopeContext = D->getDeclContext ()->isModuleScopeContext ();
1855
1855
1856
- // We consider global functions to be "type level"
1857
- if (isa<FuncDecl>(D)) {
1856
+ // We consider global functions, type aliases, and macros to be "type level"
1857
+ if (isa<FuncDecl>(D) || isa<MacroDecl>(D) || isa<TypeAliasDecl>(D) ) {
1858
1858
return IsModuleScopeContext;
1859
1859
}
1860
1860
@@ -4073,8 +4073,6 @@ class ExprAvailabilityWalker : public BaseDiagnosticWalker {
4073
4073
};
4074
4074
} // end anonymous namespace
4075
4075
4076
- llvm::DenseSet<const Decl *> reportedDecls;
4077
-
4078
4076
static void suggestUnsafeOnEnclosingDecl (
4079
4077
SourceRange referenceRange, const DeclContext *referenceDC) {
4080
4078
if (referenceRange.isInvalid ())
@@ -4092,9 +4090,6 @@ static void suggestUnsafeOnEnclosingDecl(
4092
4090
if (!decl)
4093
4091
return ;
4094
4092
4095
- if (!reportedDecls.insert (decl).second )
4096
- return ;
4097
-
4098
4093
if (versionCheckNode.has_value ()) {
4099
4094
// The unsafe construct is inside the body of the entity, so suggest
4100
4095
// @safe(unchecked) on the declaration.
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ struct X { }
10
10
11
11
@freestanding ( expression) macro m1( ) -> X = #externalMacro( module: " A " , type: " B " ) // expected-error{{'X' is only available in macOS 12.0 or newer}}
12
12
// expected-warning@-1{{external macro implementation type 'A.B' could not be found for macro 'm1()'}}
13
+ // expected-note@-2{{add @available attribute to enclosing macro}}
13
14
14
15
@available ( macOS 12 . 0 , * )
15
16
@freestanding ( expression) macro m2( ) -> X = #externalMacro( module: " A " , type: " B " )
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ func testMe(
92
92
// -----------------------------------------------------------------------
93
93
// Various declaration kinds
94
94
// -----------------------------------------------------------------------
95
+ // expected-note@+1{{make type alias 'SuperUnsafe' @unsafe to indicate that its use is not memory-safe}}{{1-1=@unsafe }}
95
96
typealias SuperUnsafe = UnsafeSuper // expected-warning{{reference to unsafe class 'UnsafeSuper' [Unsafe]}}
96
97
@unsafe typealias SuperUnsafe2 = UnsafeSuper
97
98
You can’t perform that action at this time.
0 commit comments