[clang] [C++20][Modules] Implement P1857R3 Modules Dependency Discovery (PR #107168)

Hubert Tong via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 18 21:24:49 PDT 2025


================
@@ -986,6 +989,14 @@ def warn_module_conflict : Warning<
   InGroup<ModuleConflict>;
 
 // C++20 modules
+def err_pp_module_name_is_macro : Error<
+  "%select{module|partition}0 name component %1 cannot be a object-like macro">;
+def err_pp_module_expected_ident : Error<
+  "expected %select{identifier after '.' in |}0module name">;
----------------
hubert-reinterpretcast wrote:

> Should we emit an diagnostic the `(` in line 2 in phase 7?

I think you found a bug in the resolution of CWG2947. The restriction on `(` was not extended to tokens from the next line.

As for diagnosing this in phase 7, how is phase 7 supposed to differentiate between the above and
```cpp
// #define m(x) x
// #define LPAREN (
export module m
    LPAREN foo);
```
?

For the `(` case, is there a way to look ahead to see if the next _preprocessing-token_  (at the start of phase 4) is `(`?


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


More information about the cfe-commits mailing list