14eb8393cSRichard Smith // RUN: rm -rf %t
24eb8393cSRichard Smith // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs/suggest-include %s -verify
34eb8393cSRichard Smith 
44eb8393cSRichard Smith #include "empty.h" // import the module file
54eb8393cSRichard Smith 
6*0a088eadSRichard Smith // [email protected]:2 {{here}}
7*0a088eadSRichard Smith // [email protected]:1 {{here}}
8*0a088eadSRichard Smith // [email protected]:1 {{here}}
9*0a088eadSRichard Smith // [email protected]:1 {{here}}
10*0a088eadSRichard Smith // [email protected]:1 {{here}}
11*0a088eadSRichard Smith // [email protected]:1 {{here}}
12*0a088eadSRichard Smith // [email protected]:1 {{here}}
13*0a088eadSRichard Smith // [email protected]:1 {{here}}
144eb8393cSRichard Smith 
f()154eb8393cSRichard Smith void f() {
164eb8393cSRichard Smith   (void)::usetextual1; // expected-error {{missing '#include "usetextual1.h"'}}
174eb8393cSRichard Smith   (void)::usetextual2; // expected-error {{missing '#include "usetextual2.h"'}}
184eb8393cSRichard Smith   (void)::textual3; // expected-error-re {{{{^}}missing '#include "usetextual3.h"'}}
19*0a088eadSRichard Smith   // If the declaration is in an include-guarded header, make sure we suggest
20*0a088eadSRichard Smith   // including that rather than importing a module. In this case, there could
21*0a088eadSRichard Smith   // be more than one module, and the module name we picked is almost certainly
22*0a088eadSRichard Smith   // wrong.
23*0a088eadSRichard Smith   (void)::textual4; // expected-error {{missing '#include "usetextual4.h"'; 'textual4' must be declared before it is used}}
24*0a088eadSRichard Smith   (void)::textual5; // expected-error {{missing '#include "usetextual5.h"'; 'textual5' must be declared before it is used}}
254eb8393cSRichard Smith 
264eb8393cSRichard Smith   // Don't suggest #including a private header.
274eb8393cSRichard Smith   // FIXME: We could suggest including "useprivate1.h" here, as it's the only
284eb8393cSRichard Smith   // public way to get at this declaration.
294eb8393cSRichard Smith   (void)::private1; // expected-error-re {{{{^}}declaration of 'private1'}}
304eb8393cSRichard Smith   // FIXME: Should we be suggesting an import at all here? Should declarations
314eb8393cSRichard Smith   // in private headers be visible when the surrounding module is imported?
324eb8393cSRichard Smith   (void)::private2; // expected-error-re {{{{^}}declaration of 'private2'}}
334eb8393cSRichard Smith   // Even if we suggest an include for private1, we should not do so here.
344eb8393cSRichard Smith   (void)::private3; // expected-error-re {{{{^}}declaration of 'private3'}}
354eb8393cSRichard Smith }
36