1// RUN: rm -rf %t 2// RUN: mkdir %t 3// RUN: split-file %s %t 4// 5// RUN: %clang_cc1 -std=c++20 %t/mod1.cppm -emit-module-interface -o %t/mod1.pcm 6// RUN: %clang_cc1 -std=c++20 %t/mod2.cppm -emit-module-interface -o %t/mod2.pcm 7// RUN: %clang_cc1 -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -verify 8 9//--- mod1.cppm 10export module mod1; 11export int v; 12export void func(); 13export class A {}; 14export template <class C> 15struct S {}; 16 17//--- mod2.cppm 18export module mod2; 19export int v; 20export void func(); 21export class A; 22export template <class C> 23struct S {}; 24 25//--- test.cc 26import mod1; 27import mod2; 28void test() { 29 int value = v; 30 func(); 31 A a; 32 S<int> s; 33} 34 35// expected-error@mod1.cppm:* {{declaration 'v' attached to named module 'mod1' cannot be attached to other modules}} 36// expected-note@mod2.cppm:* {{}} 37// expected-error@mod1.cppm:* {{declaration 'func' attached to named module 'mod1' cannot be attached to other modules}} 38// expected-note@mod2.cppm:* {{}} 39// expected-error@mod1.cppm:* {{declaration 'A' attached to named module 'mod1' cannot be attached to other modules}} 40// expected-note@mod2.cppm:* {{}} 41// expected-error@mod1.cppm:* 1+{{declaration 'S' attached to named module 'mod1' cannot be attached to other modules}} 42// expected-note@mod2.cppm:* 1+{{}} 43