Issue |
141580
|
Summary |
[Clang] Incorrect treatment of header guards in modular builds
|
Labels |
clang,
clang:modules
|
Assignees |
VitaNuo
|
Reporter |
VitaNuo
|
Command:
```
$(CLANG) -fmodule-name=foo -fmodule-map-file=foo.cppmap -xc++ -Xclang=-emit-module -fmodules -std=gnu++20 -c foo.cppmap -o foo.pcm
```
foo.cppmap:
```
module "foo" {
export *
header "foo.h"
module "bar" {
header "bar.h"
}
}
```
foo.h:
```
#include "baz.h"
```
baz.h:
```
#ifndef BAZ_H_
#define BAZ_H_
#include "bar.h"
namespace {
struct Baz {};
}
#endif
```
bar.h:
```
#include "baz.h"
```
Error:
```
While building module 'foo':
In file included from <module-includes>:1:
In file included from ./foo.h:1:
./baz.h:5:8: error: redefinition of 'Baz'
5 | struct Baz {};
| ^
./bar.h:1:10: note: './baz.h' included multiple times, additional include site in header from module 'foo.bar'
1 | #include "baz.h"
| ^
foo.cppmap:4:10: note: foo.bar defined here
4 | module "bar" {
| ^
./foo.h:1:10: note: './baz.h' included multiple times, additional include site in header from module 'foo'
1 | #include "baz.h"
| ^
foo.cppmap:1:8: note: foo defined here
1 | module "foo" {
| ^
1 error generated.
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs