1 // RUN: %clang_cc1 -fmodules -verify -fno-modules-error-recovery -fno-spell-checking %s 2 // RUN: %clang_cc1 -fmodules -verify -fno-modules-error-recovery -DONLY_Y %s 3 4 #pragma clang module build a 5 module a { 6 explicit module x {} 7 explicit module y {} 8 } 9 #pragma clang module contents 10 #pragma clang module begin a.x 11 namespace N { f(T)12 template<typename T> extern int f(T) { return 0; } 13 } 14 #pragma clang module end 15 16 #pragma clang module begin a.y 17 #pragma clang module import a.x 18 using N::f; 19 #pragma clang module end 20 #pragma clang module endbuild 21 22 namespace N { struct A {}; } 23 struct B {}; 24 25 #ifndef ONLY_Y 26 #pragma clang module import a.x test1()27void test1() { 28 f(N::A()); 29 f(B()); // expected-error {{use of undeclared identifier 'f'}} 30 } 31 #else 32 // expected-no-diagnostics 33 #endif 34 35 #pragma clang module import a.y test2()36void test2() { 37 // These are OK even if a.x is not imported. 38 f(N::A()); 39 f(B()); 40 } 41