Clang Project

clang_source_code/test/Modules/using-decl-friend-2.cpp
1// RUN: %clang_cc1 -fmodules %s -verify
2// expected-no-diagnostics
3
4#pragma clang module build A
5module A {}
6#pragma clang module contents
7#pragma clang module begin A
8namespace N { class X; }
9#pragma clang module end
10#pragma clang module endbuild
11
12#pragma clang module build B
13module B {}
14#pragma clang module contents
15#pragma clang module begin B
16namespace N { class Friendly { friend class X; }; }
17#pragma clang module end
18#pragma clang module endbuild
19
20#pragma clang module build C
21module C {}
22#pragma clang module contents
23#pragma clang module begin C
24#pragma clang module import A
25void use_X(N::X *p);
26#pragma clang module import B
27// UsingShadowDecl names the friend declaration
28using N::X;
29#pragma clang module end
30#pragma clang module endbuild
31
32#pragma clang module import B
33namespace N { class AlsoFriendly { friend class X; }; }
34#pragma clang module import A
35#pragma clang module import C
36// The friend declaration from N::Friendly is now the first in the redecl
37// chain, so is not ordinarily visible. We need the IDNS of the UsingShadowDecl
38// to still consider it to be visible, though.
39X *p;
40