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