# Clang C module importer bug?

**URL:** <https://forums.swift.org/t/clang-c-module-importer-bug/60894>\
**Category:** Compiler\
**Created:** [October 17, 2022, 7:10am UTC](https://forums.swift.org/t/clang-c-module-importer-bug/60894 "2022-10-17T07:10:44Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![NuriAmari](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nuriamari/32/19888_2.png) [@NuriAmari](https://forums.swift.org/u/NuriAmari)\
**Post date:** [October 17, 2022, 3:47pm UTC](https://forums.swift.org/t/clang-c-module-importer-bug/60894/4 "2022-10-17T15:47:57Z")

</div>

Hi all,

> I think there's a new-ish way to diagnose Clang importer questions such as yours, thanks to @NuriAmari’s work in [PR #39923: Improve ClangImporter Diagnostics](https://github.com/apple/swift/pull/39923). From reading the PR, I assumed you should be able to pass `-Xfrontend -enable-experimental-clang-importer-diagnostics` to the compiler, but this doesn’t work for me with your sample project with Swift 5.7 (Xcode 14.0.1 or Xcode 14.1b3) because the compiler doesn’t recognize the flag:
> 
> ```swift
> error: unknown argument: '-enable-experimental-clang-importer-diagnostics'
> 
> ```
> 
> Maybe this flag is not part of the Xcode toolchains (yet?)? I haven't tested with a current nightly toolchain. I think there's a new-ish way to diagnose Clang importer questions such as yours, thanks to @NuriAmari’s work in [PR #39923: Improve ClangImporter Diagnostics](https://github.com/apple/swift/pull/39923). From reading the PR, I assumed you should be able to pass `-Xfrontend -enable-experimental-clang-importer-diagnostics` to the compiler, but this doesn’t work for me with your sample project with Swift 5.7 (Xcode 14.0.1 or Xcode 14.1b3) because the compiler doesn’t recognize the flag:
> 
> ```swift
> error: unknown argument: '-enable-experimental-clang-importer-diagnostics'
> 
> ```
> 
> Maybe this flag is not part of the Xcode toolchains (yet?)? I haven't tested with a current nightly toolchain.

In terms of enabling the improved ClangImporter diagnostics, they are enabled by default now: [[Pitch] Lazy ClangImporter Diagnostics Enabled by Default](https://forums.swift.org/t/pitch-lazy-clangimporter-diagnostics-enabled-by-default/54651). Unfortunately, @mickeyl the case you are facing is not covered by the diagnostics.

On swift main at least, the macro is dropped here: [https://github.com/apple/swift/blob/main/lib/ClangImporter/ImportMacro.cpp#L503](https://github.com/apple/swift/blob/main/lib/ClangImporter/ImportMacro.cpp#L503). It seems I left myself a TODO to handle this case, but never got to it. Feel free to attach this post to the issue: [[SR-15429] Add Missing Macro Diagnostics to ClangImporter · Issue #57735 · apple/swift · GitHub](https://github.com/apple/swift/issues/57735). At this moment, I don't really have any advice aside from using the `__gmpz_clear` name in the interim. I don't have time to investigate further at this moment, but I will try to either improve the diagnostic or see if we can import this macro, hopefully sometime in the next week or so.

---

_[View the full topic](https://forums.swift.org/t/clang-c-module-importer-bug/60894)._
