70 lines · plain
1// RUN: rm -rf %t2// RUN: split-file %s %t3// RUN: cd %t4//5// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm6// RUN: %clang_cc1 -module-file-info %t/a.pcm | FileCheck %t/a.cppm7// RUN: %clang_cc1 -std=c++20 %t/b.cpp -fmodule-file=a=%t/a.pcm -fsyntax-only -verify8// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-module-interface -o %t/c.pcm9// RUN: %clang_cc1 -std=c++20 %t/d.cpp -fsyntax-only -verify -fmodule-file=c=%t/c.pcm10 11// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm12// RUN: %clang_cc1 -std=c++20 %t/b.cpp -fmodule-file=a=%t/a.pcm -fsyntax-only -verify13// RUN: %clang_cc1 -std=c++20 %t/c.cppm -fsyntax-only -verify14// RUN: %clang_cc1 -module-file-info %t/a.pcm | FileCheck %t/a.cppm15 16//--- a.cppm17export module a;18export extern "C++" int foo() { return 43; }19export extern "C++" {20 int a();21 int b();22 int c();23}24 25export {26 extern "C++" void f1();27 extern "C++" void f2();28 extern "C++" void f3();29}30 31extern "C++" void unexported();32 33// CHECK: Sub Modules:34// CHECK-NEXT: Implicit Module Fragment '<implicit global>'35 36//--- b.cpp37import a;38int use() {39 a();40 b();41 c();42 f1();43 f2();44 f3();45 unexported(); // expected-error {{declaration of 'unexported' must be imported from module 'a' before it is required}}46 // expected-note@a.cppm:15 {{declaration here is not visible}}47 return foo();48}49 50//--- c.cppm51// expected-no-diagnostics52export module c;53extern "C++" {54 export int f();55 int h();56}57 58extern "C++" export int g();59 60//--- d.cpp61import c;62int use() {63 return f() + g();64}65 66int use_of_nonexported() {67 return h(); // expected-error {{declaration of 'h' must be imported from module 'c' before it is required}}68 // expected-note@c.cppm:5 {{declaration here is not visible}}69}70