Skip to content

[Clang] Incorrect treatment of header guards in modular builds #141580

Open
@VitaNuo

Description

@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.

Metadata

Metadata

Assignees

Labels

clang:modulesC++20 modules and Clang Header Modules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions