Argyrios Kyrtzidis | 0c06cbc | 2013-01-23 18:21:56 +0000 | [diff] [blame] | 1 | // XFAIL: * |
Douglas Gregor | 4258332 | 2011-11-16 05:16:30 +0000 | [diff] [blame] | 2 | // RUN: rm -rf %t |
Douglas Gregor | 6c6c54a | 2012-10-11 00:46:49 +0000 | [diff] [blame] | 3 | // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=macros_top %S/Inputs/module.map |
| 4 | // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=macros_left %S/Inputs/module.map |
| 5 | // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=macros_right %S/Inputs/module.map |
Douglas Gregor | c13a34b | 2012-01-03 19:32:59 +0000 | [diff] [blame] | 6 | // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=macros %S/Inputs/module.map |
| 7 | // RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodule-cache-path %t %s |
| 8 | // RUN: %clang_cc1 -E -fmodules -x objective-c -fmodule-cache-path %t %s | FileCheck -check-prefix CHECK-PREPROCESSED %s |
| 9 | // FIXME: When we have a syntax for modules in C, use that. |
Douglas Gregor | 6c6c54a | 2012-10-11 00:46:49 +0000 | [diff] [blame] | 10 | // These notes come from headers in modules, and are bogus. |
Douglas Gregor | e8219a6 | 2012-10-11 21:07:39 +0000 | [diff] [blame] | 11 | |
Douglas Gregor | 6c6c54a | 2012-10-11 00:46:49 +0000 | [diff] [blame] | 12 | // FIXME: expected-note{{previous definition is here}} |
Douglas Gregor | e8219a6 | 2012-10-11 21:07:39 +0000 | [diff] [blame] | 13 | // expected-note{{other definition of 'LEFT_RIGHT_DIFFERENT'}} |
| 14 | // expected-note{{expanding this definition of 'TOP_RIGHT_REDEF'}} |
| 15 | // FIXME: expected-note{{previous definition is here}} \ |
| 16 | // expected-note{{expanding this definition of 'LEFT_RIGHT_DIFFERENT'}} |
| 17 | |
| 18 | // expected-note{{other definition of 'TOP_RIGHT_REDEF'}} |
Douglas Gregor | 7143aab | 2011-09-01 17:04:32 +0000 | [diff] [blame] | 19 | |
Douglas Gregor | 1b257af | 2012-12-11 22:11:52 +0000 | [diff] [blame] | 20 | @import macros; |
Douglas Gregor | 7143aab | 2011-09-01 17:04:32 +0000 | [diff] [blame] | 21 | |
| 22 | #ifndef INTEGER |
| 23 | # error INTEGER macro should be visible |
| 24 | #endif |
| 25 | |
| 26 | #ifdef FLOAT |
| 27 | # error FLOAT macro should not be visible |
| 28 | #endif |
| 29 | |
| 30 | #ifdef MODULE |
| 31 | # error MODULE macro should not be visible |
| 32 | #endif |
| 33 | |
Douglas Gregor | de8a905 | 2011-09-14 23:13:09 +0000 | [diff] [blame] | 34 | // CHECK-PREPROCESSED: double d |
Douglas Gregor | 7143aab | 2011-09-01 17:04:32 +0000 | [diff] [blame] | 35 | double d; |
| 36 | DOUBLE *dp = &d; |
| 37 | |
Douglas Gregor | 1ac13c3 | 2012-01-03 19:48:16 +0000 | [diff] [blame] | 38 | #__public_macro WIBBLE // expected-error{{no macro named 'WIBBLE'}} |
Douglas Gregor | 7143aab | 2011-09-01 17:04:32 +0000 | [diff] [blame] | 39 | |
Douglas Gregor | ce835df | 2011-09-14 22:14:14 +0000 | [diff] [blame] | 40 | void f() { |
Douglas Gregor | de8a905 | 2011-09-14 23:13:09 +0000 | [diff] [blame] | 41 | // CHECK-PREPROCESSED: int i = INTEGER; |
Douglas Gregor | ce835df | 2011-09-14 22:14:14 +0000 | [diff] [blame] | 42 | int i = INTEGER; // the value was exported, the macro was not. |
Douglas Gregor | b09de51 | 2012-09-25 15:44:52 +0000 | [diff] [blame] | 43 | i += macros; // expanded from __MODULE__ within the 'macros' module. |
Douglas Gregor | ce835df | 2011-09-14 22:14:14 +0000 | [diff] [blame] | 44 | } |
Douglas Gregor | b09de51 | 2012-09-25 15:44:52 +0000 | [diff] [blame] | 45 | |
| 46 | #ifdef __MODULE__ |
| 47 | # error Not building a module! |
| 48 | #endif |
| 49 | |
| 50 | #if __building_module(macros) |
| 51 | # error Not building a module |
| 52 | #endif |
Douglas Gregor | 6c6c54a | 2012-10-11 00:46:49 +0000 | [diff] [blame] | 53 | |
| 54 | // None of the modules we depend on have been imported, and therefore |
| 55 | // their macros should not be visible. |
| 56 | #ifdef LEFT |
| 57 | # error LEFT should not be visible |
| 58 | #endif |
| 59 | |
| 60 | #ifdef RIGHT |
| 61 | # error RIGHT should not be visible |
| 62 | #endif |
| 63 | |
| 64 | #ifdef TOP |
| 65 | # error TOP should not be visible |
| 66 | #endif |
| 67 | |
| 68 | // Import left module (which also imports top) |
Douglas Gregor | 1b257af | 2012-12-11 22:11:52 +0000 | [diff] [blame] | 69 | @import macros_left; |
Douglas Gregor | 6c6c54a | 2012-10-11 00:46:49 +0000 | [diff] [blame] | 70 | |
| 71 | #ifndef LEFT |
| 72 | # error LEFT should be visible |
| 73 | #endif |
| 74 | |
| 75 | #ifdef RIGHT |
| 76 | # error RIGHT should not be visible |
| 77 | #endif |
| 78 | |
| 79 | #ifndef TOP |
| 80 | # error TOP should be visible |
| 81 | #endif |
| 82 | |
| 83 | #ifdef TOP_LEFT_UNDEF |
| 84 | # error TOP_LEFT_UNDEF should not be visible |
| 85 | #endif |
| 86 | |
| 87 | void test1() { |
| 88 | int i; |
| 89 | TOP_RIGHT_REDEF *ip = &i; |
| 90 | } |
| 91 | |
| 92 | #define LEFT_RIGHT_DIFFERENT2 double // FIXME: expected-warning{{'LEFT_RIGHT_DIFFERENT2' macro redefined}} |
| 93 | |
| 94 | // Import right module (which also imports top) |
Douglas Gregor | 1b257af | 2012-12-11 22:11:52 +0000 | [diff] [blame] | 95 | @import macros_right; |
Douglas Gregor | 6c6c54a | 2012-10-11 00:46:49 +0000 | [diff] [blame] | 96 | |
| 97 | #undef LEFT_RIGHT_DIFFERENT3 |
| 98 | |
| 99 | #ifndef LEFT |
| 100 | # error LEFT should be visible |
| 101 | #endif |
| 102 | |
| 103 | #ifndef RIGHT |
| 104 | # error RIGHT should be visible |
| 105 | #endif |
| 106 | |
| 107 | #ifndef TOP |
| 108 | # error TOP should be visible |
| 109 | #endif |
| 110 | |
Douglas Gregor | 6c6c54a | 2012-10-11 00:46:49 +0000 | [diff] [blame] | 111 | void test2() { |
| 112 | int i; |
| 113 | float f; |
| 114 | double d; |
Douglas Gregor | e8219a6 | 2012-10-11 21:07:39 +0000 | [diff] [blame] | 115 | TOP_RIGHT_REDEF *ip = &i; // expected-warning{{ambiguous expansion of macro 'TOP_RIGHT_REDEF'}} |
Douglas Gregor | 6c6c54a | 2012-10-11 00:46:49 +0000 | [diff] [blame] | 116 | |
| 117 | LEFT_RIGHT_IDENTICAL *ip2 = &i; |
Douglas Gregor | e8219a6 | 2012-10-11 21:07:39 +0000 | [diff] [blame] | 118 | LEFT_RIGHT_DIFFERENT *fp = &f; // expected-warning{{ambiguous expansion of macro 'LEFT_RIGHT_DIFFERENT'}} |
| 119 | LEFT_RIGHT_DIFFERENT2 *dp = &d; |
Douglas Gregor | 6c6c54a | 2012-10-11 00:46:49 +0000 | [diff] [blame] | 120 | int LEFT_RIGHT_DIFFERENT3; |
| 121 | } |
| 122 | |
| 123 | #define LEFT_RIGHT_DIFFERENT double // FIXME: expected-warning{{'LEFT_RIGHT_DIFFERENT' macro redefined}} |
| 124 | |
| 125 | void test3() { |
| 126 | double d; |
| 127 | LEFT_RIGHT_DIFFERENT *dp = &d; // okay |
| 128 | } |
Douglas Gregor | 54c8a40 | 2012-10-12 00:16:50 +0000 | [diff] [blame] | 129 | |
| 130 | #ifndef TOP_RIGHT_UNDEF |
| 131 | # error TOP_RIGHT_UNDEF should still be defined |
| 132 | #endif |
| 133 | |
Douglas Gregor | 1b257af | 2012-12-11 22:11:52 +0000 | [diff] [blame] | 134 | @import macros_right.undef; |
Douglas Gregor | 54c8a40 | 2012-10-12 00:16:50 +0000 | [diff] [blame] | 135 | |
| 136 | #ifdef TOP_RIGHT_UNDEF |
| 137 | # error TOP_RIGHT_UNDEF should not be defined |
| 138 | #endif |