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