71 lines · plain
1// RUN: rm -rf %t2// RUN: mkdir %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/x.cppm -o %t/x.pcm6// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=x=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm7// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.b.cppm -o %t/a.b.pcm8//9// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -fmodule-file=x=%t/x.pcm \10// RUN: -verify %t/test.interface.cpp11// 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.implementation.cpp13// 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.cpp14 15//--- x.cppm16export module x;17export int a, b;18 19//--- x.y.cppm20export module x.y;21export int c;22 23//--- a.b.cppm24export module a.b;25export int d;26 27//--- test.x.cpp28module x;29int use_1 = a; // ok30 31int use_2 = b; // ok32 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.interface.cpp37export module z;38 39import x;40 41import x [[]];42import x [[foo]]; // expected-warning {{unknown attribute 'foo' ignored}}43import x [[noreturn]]; // expected-error {{'noreturn' attribute cannot be applied to a module import}}44import x [[blarg::noreturn]]; // expected-warning-re {{unknown attribute 'blarg::noreturn' ignored{{.*}}}}45 46import x.y;47import x.; // expected-error {{expected a module name after 'import'}}48import .x; // expected-error {{expected a module name after 'import'}}49 50import blarg; // expected-error {{module 'blarg' not found}}51 52int use_4 = c; // ok53 54//--- test.implementation.cpp55module a.b;56 57import x;58 59import x [[]];60import x [[foo]]; // expected-warning {{unknown attribute 'foo' ignored}}61import x [[noreturn]]; // expected-error {{'noreturn' attribute cannot be applied to a module import}}62import x [[blarg::noreturn]]; // expected-warning-re {{unknown attribute 'blarg::noreturn' ignored{{.*}}}}63 64import x.y;65import x.; // expected-error {{expected a module name after 'import'}}66import .x; // expected-error {{expected a module name after 'import'}}67 68import blarg; // expected-error {{module 'blarg' not found}}69 70int use_4 = c; // ok71