• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: rm -rf %t
2// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_1 -DUSE_2 -DUSE_3 -DUSE_4
3// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_2 -DUSE_3 -DUSE_4
4// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_3 -DUSE_4
5// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_4
6
7// expected-note@Inputs/def.h:5 0-1{{previous}}
8// expected-note@Inputs/def.h:16 0-1{{previous}}
9// expected-note@Inputs/def-include.h:11 0-1{{previous}}
10
11@class Def;
12Def *def;
13class Def2; // expected-note 0-1{{forward decl}}
14Def2 *def2;
15namespace Def3NS { class Def3; } // expected-note 0-1{{forward decl}}
16Def3NS::Def3 *def3;
17
18@interface Unrelated
19- defMethod;
20@end
21
22@import decldef;
23#ifdef USE_1
24A *a1; // expected-error{{declaration of 'A' must be imported from module 'decldef.Def'}}
25B *b1;
26#define USED
27#endif
28@import decldef.Decl;
29
30A *a2;
31B *b;
32
33void testA(A *a) {
34#ifdef USE_2
35  a->ivar = 17;
36  #ifndef USED
37  // expected-error@-2{{definition of 'A' must be imported from module 'decldef.Def' before it is required}}
38  #define USED
39  #endif
40#endif
41}
42
43void testB() {
44#ifdef USE_3
45  B b;
46  #ifndef USED
47  // expected-error@-2{{definition of 'B' must be imported from module 'decldef.Def' before it is required}}
48  #define USED
49  #endif
50#endif
51}
52
53void testDef() {
54  [def defMethod];
55}
56
57void testDef2() {
58#ifdef USE_4
59  def2->func();
60  def3->func();
61  #ifndef USED
62  // expected-error@-3 {{definition of 'Def2' must be imported}}
63  #define USED
64  #endif
65#endif
66}
67