1 // XFAIL: * 2 // RUN: rm -rf %t 3 // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_top %S/Inputs/module.map 4 // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_left %S/Inputs/module.map 5 // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_right %S/Inputs/module.map 6 // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros %S/Inputs/module.map 7 // RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t %s 8 // RUN: %clang_cc1 -E -fmodules -x objective-c -fmodules-cache-path=%t %s | FileCheck -check-prefix CHECK-PREPROCESSED %s 9 // FIXME: When we have a syntax for modules in C, use that. 10 // These notes come from headers in modules, and are bogus. 11 12 // FIXME: expected-note{{previous definition is here}} 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'}} 19 20 @import macros; 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 34 // CHECK-PREPROCESSED: double d 35 double d; 36 DOUBLE *dp = &d; 37 38 #__public_macro WIBBLE // expected-error{{no macro named 'WIBBLE'}} 39 f()40void f() { 41 // CHECK-PREPROCESSED: int i = INTEGER; 42 int i = INTEGER; // the value was exported, the macro was not. 43 i += macros; // expanded from __MODULE__ within the 'macros' module. 44 } 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 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) 69 @import macros_left; 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 test1()87void 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) 95 @import macros_right; 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 test2()111void test2() { 112 int i; 113 float f; 114 double d; 115 TOP_RIGHT_REDEF *ip = &i; // expected-warning{{ambiguous expansion of macro 'TOP_RIGHT_REDEF'}} 116 117 LEFT_RIGHT_IDENTICAL *ip2 = &i; 118 LEFT_RIGHT_DIFFERENT *fp = &f; // expected-warning{{ambiguous expansion of macro 'LEFT_RIGHT_DIFFERENT'}} 119 LEFT_RIGHT_DIFFERENT2 *dp = &d; 120 int LEFT_RIGHT_DIFFERENT3; 121 } 122 123 #define LEFT_RIGHT_DIFFERENT double // FIXME: expected-warning{{'LEFT_RIGHT_DIFFERENT' macro redefined}} 124 test3()125void test3() { 126 double d; 127 LEFT_RIGHT_DIFFERENT *dp = &d; // okay 128 } 129 130 #ifndef TOP_RIGHT_UNDEF 131 # error TOP_RIGHT_UNDEF should still be defined 132 #endif 133 134 @import macros_right.undef; 135 136 #ifdef TOP_RIGHT_UNDEF 137 # error TOP_RIGHT_UNDEF should not be defined 138 #endif 139