Files
swift-mirror/test/Interop/SwiftToCxx/macros/macro-name-collision.swift
Egor Zhdan f42609b7bd [cxx-interop][SwiftToCxx] Do not crash while trying to expose a macro to C++
This fixes a compiler crash that happened when emitting a Clang header for a Swift module that declares multiple macros with the same base name and different argument names.

Swift macros are not currently designed to be exposed to C++. This teaches the compiler to explicitly mark them as unavailable in C++.

rdar://117969472 / resolves https://github.com/apple/swift/issues/69656
2024-05-08 16:08:02 +01:00

17 lines
769 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend %s -typecheck -module-name MacroNameCollision -clang-header-expose-decls=all-public -emit-clang-header-path %t/macros.h
// RUN: %FileCheck %s < %t/macros.h
// RUN: %check-interop-cxx-header-in-clang(%t/macros.h)
// CHECK-LABEL: namespace MacroNameCollision SWIFT_PRIVATE_ATTR SWIFT_SYMBOL_MODULE("MacroNameCollision") {
@freestanding(expression)
public macro myLogMacro(error: String) = #externalMacro(module: "CompilerPlugin", type: "LogMacro")
@freestanding(expression)
public macro myLogMacro(fault: String) = #externalMacro(module: "CompilerPlugin", type: "LogMacro")
// CHECK: // Unavailable in C++: Swift macro 'myLogMacro(error:)'
// CHECK: // Unavailable in C++: Swift macro 'myLogMacro(fault:)'