xref: /aosp_15_r20/external/clang/test/Modules/suggest-include.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: rm -rf %t
2*67e74705SXin Li // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs/suggest-include %s -verify
3*67e74705SXin Li 
4*67e74705SXin Li #include "empty.h" // import the module file
5*67e74705SXin Li 
6*67e74705SXin Li // [email protected]:2 {{previous}}
7*67e74705SXin Li // [email protected]:1 {{previous}}
8*67e74705SXin Li // [email protected]:1 {{previous}}
9*67e74705SXin Li // [email protected]:1 {{previous}}
10*67e74705SXin Li // [email protected]:1 {{previous}}
11*67e74705SXin Li // [email protected]:1 {{previous}}
12*67e74705SXin Li // [email protected]:1 {{previous}}
13*67e74705SXin Li // [email protected]:1 {{previous}}
14*67e74705SXin Li 
f()15*67e74705SXin Li void f() {
16*67e74705SXin Li   (void)::usetextual1; // expected-error {{missing '#include "usetextual1.h"'}}
17*67e74705SXin Li   (void)::usetextual2; // expected-error {{missing '#include "usetextual2.h"'}}
18*67e74705SXin Li   (void)::textual3; // expected-error-re {{{{^}}missing '#include "usetextual3.h"'}}
19*67e74705SXin Li   // Don't suggest a #include that includes the entity via a path that leaves
20*67e74705SXin Li   // the module. In that case we can't be sure that we've picked the right header.
21*67e74705SXin Li   (void)::textual4; // expected-error-re {{{{^}}declaration of 'textual4'}}
22*67e74705SXin Li   (void)::textual5; // expected-error-re {{{{^}}declaration of 'textual5'}}
23*67e74705SXin Li 
24*67e74705SXin Li   // Don't suggest #including a private header.
25*67e74705SXin Li   // FIXME: We could suggest including "useprivate1.h" here, as it's the only
26*67e74705SXin Li   // public way to get at this declaration.
27*67e74705SXin Li   (void)::private1; // expected-error-re {{{{^}}declaration of 'private1'}}
28*67e74705SXin Li   // FIXME: Should we be suggesting an import at all here? Should declarations
29*67e74705SXin Li   // in private headers be visible when the surrounding module is imported?
30*67e74705SXin Li   (void)::private2; // expected-error-re {{{{^}}declaration of 'private2'}}
31*67e74705SXin Li   // Even if we suggest an include for private1, we should not do so here.
32*67e74705SXin Li   (void)::private3; // expected-error-re {{{{^}}declaration of 'private3'}}
33*67e74705SXin Li }
34