77 lines · plain
1// RUN: rm -rf %t2// RUN: mkdir -p %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm6// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp \7// RUN: -fsyntax-only -verify8//9// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-module-interface -o %t/B.pcm10// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp \11// RUN: -fsyntax-only -verify -DIMPORT_MODULE_B12 13//--- records.h14struct 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//--- A.cppm35module;36#include "records.h"37export module A;38export using ::A;39export using ::NoNameEntity;40export using ::U;41export constexpr A a_a{};42export constexpr NoNameEntity NoName_a{};43export constexpr U u_a{};44 45//--- B.cppm46module;47#include "records.h"48export module B;49export using ::A;50export using ::NoNameEntity;51export using ::U;52export constexpr A a_b{};53export constexpr NoNameEntity NoName_b{};54export constexpr U u_b{};55 56//--- Use.cpp57// expected-no-diagnostics58import A;59#ifdef IMPORT_MODULE_B60import B;61static_assert(__is_same(decltype(a_a), decltype(a_b)));62static_assert(__is_same(decltype(NoName_a), decltype(NoName_b)));63static_assert(__is_same(decltype(u_a), decltype(u_b)));64#endif65void 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}77