Douglas Gregor | 5536891 | 2011-12-14 16:03:29 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_1 -DUSE_2 -DUSE_3 -DUSE_4 |
| 3 | // RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_2 -DUSE_3 -DUSE_4 |
| 4 | // RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_3 -DUSE_4 |
| 5 | // RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_4 |
Douglas Gregor | 5536891 | 2011-12-14 16:03:29 +0000 | [diff] [blame] | 6 | |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 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}} |
Douglas Gregor | d07cc36 | 2012-01-02 17:18:37 +0000 | [diff] [blame] | 10 | |
Douglas Gregor | 6bd9929 | 2013-02-09 01:35:03 +0000 | [diff] [blame] | 11 | @class Def; |
| 12 | Def *def; |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 13 | class Def2; // expected-note 0-1{{forward decl}} |
Douglas Gregor | 6bd9929 | 2013-02-09 01:35:03 +0000 | [diff] [blame] | 14 | Def2 *def2; |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 15 | namespace Def3NS { class Def3; } // expected-note 0-1{{forward decl}} |
Richard Smith | b716558 | 2013-09-09 07:34:56 +0000 | [diff] [blame] | 16 | Def3NS::Def3 *def3; |
Douglas Gregor | 6bd9929 | 2013-02-09 01:35:03 +0000 | [diff] [blame] | 17 | |
| 18 | @interface Unrelated |
| 19 | - defMethod; |
| 20 | @end |
| 21 | |
Douglas Gregor | 1b257af | 2012-12-11 22:11:52 +0000 | [diff] [blame] | 22 | @import decldef; |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 23 | #ifdef USE_1 |
Richard Smith | d67679d | 2013-08-20 20:35:18 +0000 | [diff] [blame] | 24 | A *a1; // expected-error{{declaration of 'A' must be imported from module 'decldef.Def'}} |
| 25 | B *b1; |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 26 | #define USED |
Richard Smith | d67679d | 2013-08-20 20:35:18 +0000 | [diff] [blame] | 27 | #endif |
Douglas Gregor | 1b257af | 2012-12-11 22:11:52 +0000 | [diff] [blame] | 28 | @import decldef.Decl; |
Douglas Gregor | 5536891 | 2011-12-14 16:03:29 +0000 | [diff] [blame] | 29 | |
Douglas Gregor | d63348c | 2011-12-15 20:36:27 +0000 | [diff] [blame] | 30 | A *a2; |
Douglas Gregor | 5536891 | 2011-12-14 16:03:29 +0000 | [diff] [blame] | 31 | B *b; |
| 32 | |
Douglas Gregor | d07cc36 | 2012-01-02 17:18:37 +0000 | [diff] [blame] | 33 | void testA(A *a) { |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 34 | #ifdef USE_2 |
Richard Smith | d67679d | 2013-08-20 20:35:18 +0000 | [diff] [blame] | 35 | a->ivar = 17; |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 36 | #ifndef USED |
Richard Smith | d67679d | 2013-08-20 20:35:18 +0000 | [diff] [blame] | 37 | // expected-error@-2{{definition of 'A' must be imported from module 'decldef.Def' before it is required}} |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 38 | #define USED |
| 39 | #endif |
Richard Smith | d67679d | 2013-08-20 20:35:18 +0000 | [diff] [blame] | 40 | #endif |
Douglas Gregor | d07cc36 | 2012-01-02 17:18:37 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Douglas Gregor | 5536891 | 2011-12-14 16:03:29 +0000 | [diff] [blame] | 43 | void testB() { |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 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 |
Douglas Gregor | 5536891 | 2011-12-14 16:03:29 +0000 | [diff] [blame] | 51 | } |
Douglas Gregor | 6bd9929 | 2013-02-09 01:35:03 +0000 | [diff] [blame] | 52 | |
| 53 | void testDef() { |
| 54 | [def defMethod]; |
| 55 | } |
| 56 | |
| 57 | void testDef2() { |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 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 |
Douglas Gregor | 6bd9929 | 2013-02-09 01:35:03 +0000 | [diff] [blame] | 66 | } |