[C++20] [Modules] Namespace Declaration shouldn't have module linkage
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>
Wed, 8 Dec 2021 05:49:02 +0000 (13:49 +0800)
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>
Wed, 8 Dec 2021 05:54:04 +0000 (13:54 +0800)
commit60f826663d86e9bdf7adef9a8f1b2fc398e07f2a
tree0d23c37ad15f6124e667b8e75fabd893945b69b2
parentdd1abb1102daeb5a54c18cec6c148e62437c1ef2
[C++20] [Modules] Namespace Declaration shouldn't have module linkage

According to [basic.namespace.general]/p2, a namespace declaration
shouldn't have a module linkage.
> A namespace is never attached to a named module and never has a name
> with module linkage.

Without this patch, the compiler would crash for the test in assertion
enabled build due to inconsistent linkage for redeclaration for
namespaces.

Reviewed by: rsmith

Differential Revision: https://reviews.llvm.org/D115132
clang/lib/AST/Decl.cpp
clang/test/CXX/basic/basic.namespace/basic.namespace.general/Inputs/p2.cppm [new file with mode: 0644]
clang/test/CXX/basic/basic.namespace/basic.namespace.general/Inputs/p2.h [new file with mode: 0644]
clang/test/CXX/basic/basic.namespace/basic.namespace.general/p2.cppm [new file with mode: 0644]