| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: mkdir -p %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
// |
| 5 |
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm |
| 6 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp \ |
| 7 |
// RUN: -fsyntax-only -verify |
| 8 |
// |
| 9 |
// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-module-interface -o %t/B.pcm |
| 10 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp \ |
| 11 |
// RUN: -fsyntax-only -verify -DIMPORT_MODULE_B |
| 12 |
|
| 13 |
//--- records.h |
| 14 |
struct A { |
| 15 |
int a; |
| 16 |
int b; |
| 17 |
int c; |
| 18 |
}; |
| 19 |
|
| 20 |
struct NoNameEntity { |
| 21 |
struct { |
| 22 |
int a; |
| 23 |
int b; |
| 24 |
int c; |
| 25 |
}; |
| 26 |
}; |
| 27 |
|
| 28 |
union U { |
| 29 |
int a; |
| 30 |
int b; |
| 31 |
int c; |
| 32 |
}; |
| 33 |
|
| 34 |
//--- A.cppm |
| 35 |
module; |
| 36 |
#include "records.h" |
| 37 |
export module A; |
| 38 |
export using ::A; |
| 39 |
export using ::NoNameEntity; |
| 40 |
export using ::U; |
| 41 |
export constexpr A a_a{}; |
| 42 |
export constexpr NoNameEntity NoName_a{}; |
| 43 |
export constexpr U u_a{}; |
| 44 |
|
| 45 |
//--- B.cppm |
| 46 |
module; |
| 47 |
#include "records.h" |
| 48 |
export module B; |
| 49 |
export using ::A; |
| 50 |
export using ::NoNameEntity; |
| 51 |
export using ::U; |
| 52 |
export constexpr A a_b{}; |
| 53 |
export constexpr NoNameEntity NoName_b{}; |
| 54 |
export constexpr U u_b{}; |
| 55 |
|
| 56 |
//--- Use.cpp |
| 57 |
// expected-no-diagnostics |
| 58 |
import A; |
| 59 |
#ifdef IMPORT_MODULE_B |
| 60 |
import B; |
| 61 |
static_assert(__is_same(decltype(a_a), decltype(a_b))); |
| 62 |
static_assert(__is_same(decltype(NoName_a), decltype(NoName_b))); |
| 63 |
static_assert(__is_same(decltype(u_a), decltype(u_b))); |
| 64 |
#endif |
| 65 |
void use1() { |
| 66 |
A a; // Shouldn't be ambiguous after import B; |
| 67 |
a.a = 43; |
| 68 |
a.b = 44; |
| 69 |
a.c = 45; |
| 70 |
NoNameEntity Anonymous; |
| 71 |
Anonymous.a = 46; |
| 72 |
Anonymous.b = 47; |
| 73 |
Anonymous.c = 48; |
| 74 |
U u; |
| 75 |
u.a = 43; |
| 76 |
} |