[clang] [C++20] [Modules] Warn if we found #include <filename> in module purview (PR #69555)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 2 19:57:14 PDT 2023


MaskRay wrote:

> > FWIW, we saw failures at Google (where, to the best of my knowledge, we aren't using named modules at all) that look like this:
> > ```
> > error: '#include <filename>' attaches the declarations to the named module '.get', which is not usually intended; consider moving that directive before the module declaration [-Werror,-Winclude-angled-in-module-purview]
> >    14 | #include <stddef.h>
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > So there's probably some problems with this patch? is this enough to go on, or would a reduced test case be required to address the issue? (reducing modules issues is a bit difficult/expensive, or I'd have provided it up front)
> 
> Since the patch itself is pretty simple, if there is a problem, it should come from the implementation `Preprocessor::isInNamedModule()`. It should be helpful to provide a reproducer so that we can be sure we're facing the same issue.

See #71134 :)

```cpp
struct module {}; void foo(module a);
#include <stdio.h>
```

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


More information about the cfe-commits mailing list