1 // Clear and create directories 2 // RUN: rm -rf %t 3 // RUN: mkdir %t 4 // RUN: mkdir %t/cache 5 // RUN: mkdir %t/Inputs 6 7 // Build first header file 8 // RUN: echo "#define FIRST" >> %t/Inputs/first.h 9 // RUN: cat %s >> %t/Inputs/first.h 10 11 // Build second header file 12 // RUN: echo "#define SECOND" >> %t/Inputs/second.h 13 // RUN: cat %s >> %t/Inputs/second.h 14 15 // Test that each header can compile 16 // RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++11 %t/Inputs/first.h -fzvector 17 // RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++11 %t/Inputs/second.h -fzvector 18 19 // Build module map file 20 // RUN: echo "module FirstModule {" >> %t/Inputs/module.map 21 // RUN: echo " header \"first.h\"" >> %t/Inputs/module.map 22 // RUN: echo "}" >> %t/Inputs/module.map 23 // RUN: echo "module SecondModule {" >> %t/Inputs/module.map 24 // RUN: echo " header \"second.h\"" >> %t/Inputs/module.map 25 // RUN: echo "}" >> %t/Inputs/module.map 26 27 // Run test 28 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x c++ -I%t/Inputs -verify %s -std=c++11 -fzvector 29 30 #if !defined(FIRST) && !defined(SECOND) 31 #include "first.h" 32 #include "second.h" 33 #endif 34 35 namespace Types { 36 namespace Vector { 37 #if defined(FIRST) 38 struct Invalid1 { 39 __attribute((vector_size(8))) int x; 40 }; 41 struct Invalid2 { 42 __attribute((vector_size(8))) int x; 43 }; 44 struct Invalid3 { 45 __attribute((vector_size(16))) int x; 46 }; 47 struct Valid { 48 __attribute((vector_size(8))) int x1; 49 __attribute((vector_size(16))) int x2; 50 __attribute((vector_size(8))) unsigned x3; 51 __attribute((vector_size(16))) long x4; 52 vector unsigned x5; 53 vector int x6; 54 }; 55 #elif defined(SECOND) 56 struct Invalid1 { 57 __attribute((vector_size(16))) int x; 58 }; 59 struct Invalid2 { 60 __attribute((vector_size(8))) unsigned x; 61 }; 62 struct Invalid3 { 63 vector unsigned x; 64 }; 65 struct Valid { 66 __attribute((vector_size(8))) int x1; 67 __attribute((vector_size(16))) int x2; 68 __attribute((vector_size(8))) unsigned x3; 69 __attribute((vector_size(16))) long x4; 70 vector unsigned x5; 71 vector int x6; 72 }; 73 #else 74 Invalid1 i1; 75 // expected-error@second.h:* {{'Types::Vector::Invalid1::x' from module 'SecondModule' is not present in definition of 'Types::Vector::Invalid1' in module 'FirstModule'}} 76 // expected-note@first.h:* {{declaration of 'x' does not match}} 77 Invalid2 i2; 78 // expected-error@second.h:* {{'Types::Vector::Invalid2::x' from module 'SecondModule' is not present in definition of 'Types::Vector::Invalid2' in module 'FirstModule'}} 79 // expected-note@first.h:* {{declaration of 'x' does not match}} 80 Invalid3 i3; 81 // expected-error@second.h:* {{'Types::Vector::Invalid3::x' from module 'SecondModule' is not present in definition of 'Types::Vector::Invalid3' in module 'FirstModule'}} 82 // expected-note@first.h:* {{declaration of 'x' does not match}} 83 84 Valid v; 85 #endif 86 } // namespace Vector 87 88 89 90 namespace ExtVector { 91 } // namespace ExtVector 92 #if defined(FIRST) 93 struct Invalid { 94 using f = __attribute__((ext_vector_type(4))) float; 95 }; 96 struct Valid { 97 using f = __attribute__((ext_vector_type(8))) float; 98 }; 99 #elif defined(SECOND) 100 struct Invalid { 101 using f = __attribute__((ext_vector_type(8))) float; 102 }; 103 struct Valid { 104 using f = __attribute__((ext_vector_type(8))) float; 105 }; 106 #else 107 Invalid i; 108 // expected-error@first.h:* {{'Types::Invalid::f' from module 'FirstModule' is not present in definition of 'Types::Invalid' in module 'SecondModule'}} 109 // expected-note@second.h:* {{declaration of 'f' does not match}} 110 111 Valid v; 112 #endif 113 114 } // namespace Types 115 116 117 // Keep macros contained to one file. 118 #ifdef FIRST 119 #undef FIRST 120 #endif 121 122 #ifdef SECOND 123 #undef SECOND 124 #endif 125 126 #ifdef ACCESS 127 #undef ACCESS 128 #endif 129