xref: /aosp_15_r20/external/clang/test/Modules/hidden-definition.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: rm -rf %t
2*67e74705SXin Li // RUN: mkdir %t
3*67e74705SXin Li // RUN: echo 'struct X {}; struct Y : X { friend int f(Y); };' > %t/a.h
4*67e74705SXin Li // RUN: echo 'module a { header "a.h" }' > %t/map
5*67e74705SXin Li // RUN: %clang_cc1 -fmodules -x c++ -emit-module -fmodule-name=a %t/map -o %t/a.pcm
6*67e74705SXin Li // RUN: %clang_cc1 -fmodules -x c++ -verify -fmodule-file=%t/a.pcm %s -fno-modules-error-recovery
7*67e74705SXin Li 
8*67e74705SXin Li struct X;
9*67e74705SXin Li struct Y;
10*67e74705SXin Li 
11*67e74705SXin Li // Ensure that we can't use the definitions of X and Y, since we've not imported module a.
12*67e74705SXin Li Y *yp;
13*67e74705SXin Li X *xp = yp; // expected-error {{cannot initialize}}
14*67e74705SXin Li _Static_assert(!__is_convertible(Y*, X*), "");
15*67e74705SXin Li X &xr = *yp; // expected-error {{unrelated type}}
g(Y & y)16*67e74705SXin Li int g(Y &y) { f(y); } // expected-error {{undeclared identifier 'f'}}
17