41 lines · cpp
1// RUN: %clang_cc1 -fmodules -verify -fno-modules-error-recovery -fno-spell-checking %s2// RUN: %clang_cc1 -fmodules -verify -fno-modules-error-recovery -DONLY_Y %s3 4#pragma clang module build a5module a {6 explicit module x {}7 explicit module y {}8}9#pragma clang module contents10#pragma clang module begin a.x11namespace N {12 template<typename T> extern int f(T) { return 0; }13}14#pragma clang module end15 16#pragma clang module begin a.y17#pragma clang module import a.x18using N::f;19#pragma clang module end20#pragma clang module endbuild21 22namespace N { struct A {}; }23struct B {};24 25#ifndef ONLY_Y26#pragma clang module import a.x27void test1() {28 f(N::A());29 f(B()); // expected-error {{use of undeclared identifier 'f'}}30}31#else32// expected-no-diagnostics33#endif34 35#pragma clang module import a.y36void test2() {37 // These are OK even if a.x is not imported.38 f(N::A());39 f(B());40}41