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) {
18531853
18541854 bool IsModuleScopeContext = D->getDeclContext ()->isModuleScopeContext ();
18551855
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) ) {
18581858 return IsModuleScopeContext;
18591859 }
18601860
@@ -4073,8 +4073,6 @@ class ExprAvailabilityWalker : public BaseDiagnosticWalker {
40734073};
40744074} // end anonymous namespace
40754075
4076- llvm::DenseSet<const Decl *> reportedDecls;
4077-
40784076static void suggestUnsafeOnEnclosingDecl (
40794077 SourceRange referenceRange, const DeclContext *referenceDC) {
40804078 if (referenceRange.isInvalid ())
@@ -4092,9 +4090,6 @@ static void suggestUnsafeOnEnclosingDecl(
40924090 if (!decl)
40934091 return ;
40944092
4095- if (!reportedDecls.insert (decl).second )
4096- return ;
4097-
40984093 if (versionCheckNode.has_value ()) {
40994094 // The unsafe construct is inside the body of the entity, so suggest
41004095 // @safe(unchecked) on the declaration.
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ struct X { }
1010
1111@freestanding ( expression) macro m1( ) -> X = #externalMacro( module: " A " , type: " B " ) // expected-error{{'X' is only available in macOS 12.0 or newer}}
1212// 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}}
1314
1415@available ( macOS 12 . 0 , * )
1516@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(
9292// -----------------------------------------------------------------------
9393// Various declaration kinds
9494// -----------------------------------------------------------------------
95+ // expected-note@+1{{make type alias 'SuperUnsafe' @unsafe to indicate that its use is not memory-safe}}{{1-1=@unsafe }}
9596typealias SuperUnsafe = UnsafeSuper // expected-warning{{reference to unsafe class 'UnsafeSuper' [Unsafe]}}
9697@unsafe typealias SuperUnsafe2 = UnsafeSuper
9798
You can’t perform that action at this time.
0 commit comments