1// RUN: rm -rf %t 2// RUN: mkdir %t 3// RUN: split-file %s %t 4// 5// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/x.cppm -o %t/x.pcm 6// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=x=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm 7// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.b.cppm -o %t/a.b.pcm 8// 9// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -fmodule-file=x=%t/x.pcm -verify %t/test.cpp \ 10// RUN: -DMODULE_NAME=z -DINTERFACE 11// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -fmodule-file=x=%t/x.pcm \ 12// RUN: -fmodule-file=a.b=%t/a.b.pcm -verify %t/test.cpp -DMODULE_NAME=a.b 13// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -fmodule-file=x=%t/x.pcm -verify %t/test.x.cpp 14 15//--- x.cppm 16export module x; 17export int a, b; 18 19//--- x.y.cppm 20export module x.y; 21export int c; 22 23//--- a.b.cppm 24export module a.b; 25export int d; 26 27//--- test.x.cpp 28module x; 29int use_1 = a; // ok 30 31int use_2 = b; // ok 32 33// There is no relation between module x and module x.y. 34int use_3 = c; // expected-error {{use of undeclared identifier 'c'}} 35 36//--- test.cpp 37#ifdef INTERFACE 38export module MODULE_NAME; 39#else 40module MODULE_NAME; 41#endif 42 43import x; 44 45import x [[]]; 46import x [[foo]]; // expected-warning {{unknown attribute 'foo' ignored}} 47import x [[noreturn]]; // expected-error {{'noreturn' attribute cannot be applied to a module import}} 48import x [[blarg::noreturn]]; // expected-warning {{unknown attribute 'noreturn' ignored}} 49 50import x.y; 51import x.; // expected-error {{expected a module name after 'import'}} 52import .x; // expected-error {{expected a module name after 'import'}} 53 54import blarg; // expected-error {{module 'blarg' not found}} 55 56int use_4 = c; // ok 57