[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / odr_hash-vector.cpp
blobe2da431a7325566c8101976434435398094e1786
1 // Clear and create directories
2 // RUN: rm -rf %t
3 // RUN: mkdir %t
4 // RUN: mkdir %t/cache
5 // RUN: mkdir %t/Inputs
7 // Build first header file
8 // RUN: echo "#define FIRST" >> %t/Inputs/first.h
9 // RUN: cat %s >> %t/Inputs/first.h
11 // Build second header file
12 // RUN: echo "#define SECOND" >> %t/Inputs/second.h
13 // RUN: cat %s >> %t/Inputs/second.h
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
19 // Build module map file
20 // RUN: echo "module FirstModule {" >> %t/Inputs/module.modulemap
21 // RUN: echo " header \"first.h\"" >> %t/Inputs/module.modulemap
22 // RUN: echo "}" >> %t/Inputs/module.modulemap
23 // RUN: echo "module SecondModule {" >> %t/Inputs/module.modulemap
24 // RUN: echo " header \"second.h\"" >> %t/Inputs/module.modulemap
25 // RUN: echo "}" >> %t/Inputs/module.modulemap
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
30 #if !defined(FIRST) && !defined(SECOND)
31 #include "first.h"
32 #include "second.h"
33 #endif
35 namespace Types {
36 namespace Vector {
37 #if defined(FIRST)
38 struct Invalid1 {
39 __attribute((vector_size(8))) int x;
41 struct Invalid2 {
42 __attribute((vector_size(8))) int x;
44 struct Invalid3 {
45 __attribute((vector_size(16))) int x;
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;
55 #elif defined(SECOND)
56 struct Invalid1 {
57 __attribute((vector_size(16))) int x;
59 struct Invalid2 {
60 __attribute((vector_size(8))) unsigned x;
62 struct Invalid3 {
63 vector unsigned x;
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;
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}}
84 Valid v;
85 #endif
86 } // namespace Vector
90 namespace ExtVector {
91 } // namespace ExtVector
92 #if defined(FIRST)
93 struct Invalid {
94 using f = __attribute__((ext_vector_type(4))) float;
96 struct Valid {
97 using f = __attribute__((ext_vector_type(8))) float;
99 #elif defined(SECOND)
100 struct Invalid {
101 using f = __attribute__((ext_vector_type(8))) float;
103 struct Valid {
104 using f = __attribute__((ext_vector_type(8))) float;
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}}
111 Valid v;
112 #endif
114 } // namespace Types
117 // Keep macros contained to one file.
118 #ifdef FIRST
119 #undef FIRST
120 #endif
122 #ifdef SECOND
123 #undef SECOND
124 #endif
126 #ifdef ACCESS
127 #undef ACCESS
128 #endif