llvm-project/clang/test/Modules/pr102721.cppm
Chuanqi Xu 55cdb3c785
[C++20] [Modules] Merge lambdas in source to imported lambdas (#106483)
Close https://github.com/llvm/llvm-project/issues/102721

Generally, the type of merged decls will be reused in ASTContext. But
for lambda, in the import and then include case, we can't decide its
previous decl in the imported modules so that we can't assign the
previous decl before creating the type for it. Since we can't decide its
numbering before creating it. So we have to assign the previous decl and
the canonical type for it after creating it, which is unusual and
slightly hack.
2024-08-29 12:37:56 +08:00

34 lines
633 B
C++

// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm \
// RUN: -fprebuilt-module-path=%t
// RUN: %clang_cc1 -std=c++20 %t/test.cc -fsyntax-only -verify \
// RUN: -fprebuilt-module-path=%t
//--- foo.h
inline auto x = []{};
//--- a.cppm
module;
#include "foo.h"
export module a;
export using ::x;
//--- b.cppm
module;
import a;
#include "foo.h"
export module b;
export using ::x;
//--- test.cc
// expected-no-diagnostics
import a;
import b;
void test() {
x();
}