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; 12 Def *def; 13 class Def2; // expected-note 0-1{{forward decl}} 14 Def2 *def2; 15 namespace Def3NS { class Def3; } // expected-note 0-1{{forward decl}} 16 Def3NS::Def3 *def3; 17 18 @interface Unrelated 19 - defMethod; 20 @end 21 22 @import decldef; 23 #ifdef USE_1 24 A *a1; // expected-error{{declaration of 'A' must be imported from module 'decldef.Def'}} 25 B *b1; 26 #define USED 27 #endif 28 @import decldef.Decl; 29 30 A *a2; 31 B *b; 32 33 void 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 43 void 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 53 void testDef() { 54 [def defMethod]; 55 } 56 57 void 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