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 14struct A { 15 int a; 16 int b; 17 int c; 18}; 19 20struct NoNameEntity { 21 struct { 22 int a; 23 int b; 24 int c; 25 }; 26}; 27 28union U { 29 int a; 30 int b; 31 int c; 32}; 33 34//--- another_records.h 35struct A { 36 int a; 37 double b; 38 float c; 39}; 40 41struct NoNameEntity { 42 struct { 43 int a; 44 unsigned b; 45 long c; 46 }; 47}; 48 49union U { 50 int a; 51 double b; 52 short c; 53}; 54 55//--- A.cppm 56module; 57#include "records.h" 58export module A; 59export using ::A; 60export using ::NoNameEntity; 61export using ::U; 62export constexpr A a_a{}; 63export constexpr NoNameEntity NoName_a{}; 64export constexpr U u_a{}; 65 66//--- B.cppm 67module; 68#include "records.h" 69export module B; 70export using ::A; 71export using ::NoNameEntity; 72export using ::U; 73export constexpr A a_b{}; 74export constexpr NoNameEntity NoName_b{}; 75export constexpr U u_b{}; 76 77//--- Use.cpp 78// expected-no-diagnostics 79import A; 80#ifdef IMPORT_MODULE_B 81import B; 82static_assert(__is_same(decltype(a_a), decltype(a_b))); 83static_assert(__is_same(decltype(NoName_a), decltype(NoName_b))); 84static_assert(__is_same(decltype(u_a), decltype(u_b))); 85#endif 86void use1() { 87 A a; // Shouldn't be ambiguous after import B; 88 a.a = 43; 89 a.b = 44; 90 a.c = 45; 91 NoNameEntity Anonymous; 92 Anonymous.a = 46; 93 Anonymous.b = 47; 94 Anonymous.c = 48; 95 U u; 96 u.a = 43; 97} 98