1// RUN: rm -rf %t
2// RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_EARLY
3// RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify
4
5// expected-note@Inputs/def.h:5 {{previous}}
6
7@class Def;
8Def *def;
9class Def2; // expected-note {{forward decl}}
10Def2 *def2;
11namespace Def3NS { class Def3; } // expected-note {{forward decl}}
12Def3NS::Def3 *def3;
13
14@interface Unrelated
15- defMethod;
16@end
17
18@import decldef;
19#ifdef USE_EARLY
20A *a1; // expected-error{{declaration of 'A' must be imported from module 'decldef.Def'}}
21B *b1;
22#endif
23@import decldef.Decl;
24
25A *a2;
26B *b;
27
28void testA(A *a) {
29  a->ivar = 17;
30#ifndef USE_EARLY
31  // expected-error@-2{{definition of 'A' must be imported from module 'decldef.Def' before it is required}}
32#endif
33}
34
35void testB() {
36  B b; // Note: redundant error silenced
37}
38
39void testDef() {
40  [def defMethod];
41}
42
43void testDef2() {
44  // FIXME: These should both work, since we've (implicitly) imported
45  // decldef.Def here, but they don't, because nothing has triggered the lazy
46  // loading of the definitions of these classes.
47  def2->func(); // expected-error {{incomplete}}
48  def3->func(); // expected-error {{incomplete}}
49}
50