Files
swift-mirror/test/PrintAsObjC/cdecl-enum-reference.swift
Alexis Laferrière dec3c895d0 PrintAsClang: Remove typedef from @objc enum forward declarations
An extra `typedef` on enum forward declarations in Objective-C +
C-pre-11 mode could cause warnings in the generated compatibility
header: `warning: redefinition of typedef 'MyEnum' is a C11 feature`.
Limit emitting that `typedef` only for C dialects without support for an
enum raw type.

rdar://164505307
2026-01-06 14:30:07 -08:00

42 lines
1.2 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: split-file %s %t
/// Build CoreLib defining a @c enum.
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) \
// RUN: %t/CoreLib.swift -emit-module -verify -o %t \
// RUN: -emit-clang-header-path %t/CoreLib.h
// RUN: %check-in-clang-c %t/CoreLib.h -I %t
/// Build MiddleLib using the @c enum in API.
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) \
// RUN: %t/MiddleLib.swift -emit-module -verify -o %t -I %t \
// RUN: -emit-clang-header-path %t/MiddleLib.h
// RUN: %FileCheck %s --input-file %t/MiddleLib.h
// RUN: %check-in-clang-c %t/MiddleLib.h -I %t
/// Build a client.
// RUN: %clang-no-modules -c %t/Client.c -I %t \
// RUN: -F %S/../Inputs/clang-importer-sdk-path/frameworks \
// RUN: -I %clang-include-dir -Werror \
// RUN: -isysroot %S/../Inputs/clang-importer-sdk
//--- CoreLib.swift
@c(CEnum)
public enum CEnum: CInt { case A, B }
//--- MiddleLib.swift
import CoreLib
@c(CFunc)
public func CFunc(e: CEnum) {}
// CHECK: SWIFT_ENUM_FWD_DECL(int, CEnum)
// CHECK: SWIFT_EXTERN void CFunc(SWIFT_ENUM_TAG CEnum e) SWIFT_NOEXCEPT;
//--- Client.c
#include "CoreLib.h"
#include "MiddleLib.h"
int main() {
CFunc(CEnumA);
}