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