[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / odr_hash.cl
blob474da6e62f159750558c506bdfd03d1505bb9106
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++ %t/Inputs/first.h -cl-std=CL2.0
17 // RUN: %clang_cc1 -fsyntax-only -x c++ %t/Inputs/second.h -cl-std=CL2.0
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 -cl-std=CL2.0
30 #if !defined(FIRST) && !defined(SECOND)
31 #include "first.h"
32 #include "second.h"
33 #endif
36 #if defined(FIRST)
37 void invalid1() {
38 typedef read_only pipe int x;
40 void invalid2() {
41 typedef read_only pipe int x;
43 void valid() {
44 typedef read_only pipe int x;
45 typedef write_only pipe int y;
46 typedef read_write pipe int z;
48 #elif defined(SECOND)
49 void invalid1() {
50 typedef write_only pipe int x;
52 void invalid2() {
53 typedef read_only pipe float x;
55 void valid() {
56 typedef read_only pipe int x;
57 typedef write_only pipe int y;
58 typedef read_write pipe int z;
60 #else
61 void run() {
62 invalid1();
63 // expected-error@second.h:* {{'invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
64 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
65 invalid2();
66 // expected-error@second.h:* {{'invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
67 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
68 valid();
70 #endif
73 // Keep macros contained to one file.
74 #ifdef FIRST
75 #undef FIRST
76 #endif
78 #ifdef SECOND
79 #undef SECOND
80 #endif