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