[clang] [C++][Modules] Import declaration should in global module fragment, module interface or module implementation (PR #164106)

via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 19 10:02:52 PDT 2025


yronglin wrote:

> I am unaware of any such restriction. An _pp-import_ is a _control-line_, which is in turn a _group-part_. A _preprocessing-file_ can directly contain a _group_ without being a _module-file_.
> 
> There _is_ a restriction on _pp-global-module-fragment_‌s: at the start of phase 4, they can contain neither a _pp-import_ nor a _text-line_.

Thanks, got it! I misunderstand before. 
[cpp.pre]/p4:
At the start of phase 4 of translation, the [group](https://eel.is/c++draft/cpp.pre#nt:group) of a [pp-global-module-fragment](https://eel.is/c++draft/cpp.pre#nt:pp-global-module-fragment) shall contain neither a [text-line](https://eel.is/c++draft/cpp.pre#nt:text-line) nor a [pp-import](https://eel.is/c++draft/cpp.import#nt:pp-import)[.](https://eel.is/c++draft/cpp.pre#4.sentence-1).is/c++draft/cpp.pre#4.sentence-1)


https://github.com/llvm/llvm-project/pull/164106


More information about the cfe-commits mailing list