xref: /aosp_15_r20/external/clang/test/Modules/merge-target-features.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: rm -rf %t
2*67e74705SXin Li // RUN: cd %S
3*67e74705SXin Li // REQUIRES: x86-registered-target
4*67e74705SXin Li // RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
5*67e74705SXin Li // RUN:   -iquote Inputs/merge-target-features \
6*67e74705SXin Li // RUN:   -fno-implicit-modules \
7*67e74705SXin Li // RUN:   -fmodule-map-file-home-is-cwd \
8*67e74705SXin Li // RUN:   -emit-module -fmodule-name=foo -o %t/foo.pcm \
9*67e74705SXin Li // RUN:   -triple i386-unknown-unknown \
10*67e74705SXin Li // RUN:   -target-cpu i386 -target-feature +sse2 \
11*67e74705SXin Li // RUN:   Inputs/merge-target-features/module.modulemap
12*67e74705SXin Li //
13*67e74705SXin Li // RUN: not %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
14*67e74705SXin Li // RUN:   -iquote Inputs/merge-target-features \
15*67e74705SXin Li // RUN:   -fno-implicit-modules \
16*67e74705SXin Li // RUN:   -fmodule-map-file-home-is-cwd \
17*67e74705SXin Li // RUN:   -fmodule-map-file=Inputs/merge-target-features/module.modulemap \
18*67e74705SXin Li // RUN:   -fmodule-file=%t/foo.pcm \
19*67e74705SXin Li // RUN:   -triple i386-unknown-unknown \
20*67e74705SXin Li // RUN:   -target-cpu i386 \
21*67e74705SXin Li // RUN:   -fsyntax-only merge-target-features.cpp 2>&1 \
22*67e74705SXin Li // RUN:   | FileCheck --check-prefix=SUBSET %s
23*67e74705SXin Li // SUBSET-NOT: error:
24*67e74705SXin Li // SUBSET: error: {{.*}} configuration mismatch
25*67e74705SXin Li // SUBSET-NOT: error:
26*67e74705SXin Li //
27*67e74705SXin Li // RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
28*67e74705SXin Li // RUN:   -iquote Inputs/merge-target-features \
29*67e74705SXin Li // RUN:   -fno-implicit-modules \
30*67e74705SXin Li // RUN:   -fmodule-map-file-home-is-cwd \
31*67e74705SXin Li // RUN:   -fmodule-map-file=Inputs/merge-target-features/module.modulemap \
32*67e74705SXin Li // RUN:   -fmodule-file=%t/foo.pcm \
33*67e74705SXin Li // RUN:   -triple i386-unknown-unknown \
34*67e74705SXin Li // RUN:   -target-cpu i386 -target-feature +sse2 \
35*67e74705SXin Li // RUN:   -fsyntax-only merge-target-features.cpp 2>&1 \
36*67e74705SXin Li // RUN:   | FileCheck --allow-empty --check-prefix=SAME %s
37*67e74705SXin Li // SAME-NOT: error:
38*67e74705SXin Li //
39*67e74705SXin Li // RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
40*67e74705SXin Li // RUN:   -iquote Inputs/merge-target-features \
41*67e74705SXin Li // RUN:   -fno-implicit-modules \
42*67e74705SXin Li // RUN:   -fmodule-map-file-home-is-cwd \
43*67e74705SXin Li // RUN:   -fmodule-map-file=Inputs/merge-target-features/module.modulemap \
44*67e74705SXin Li // RUN:   -fmodule-file=%t/foo.pcm \
45*67e74705SXin Li // RUN:   -triple i386-unknown-unknown \
46*67e74705SXin Li // RUN:   -target-cpu i386 -target-feature +sse2 -target-feature +sse3 \
47*67e74705SXin Li // RUN:   -fsyntax-only merge-target-features.cpp 2>&1 \
48*67e74705SXin Li // RUN:   | FileCheck --allow-empty --check-prefix=SUPERSET %s
49*67e74705SXin Li // SUPERSET-NOT: error:
50*67e74705SXin Li //
51*67e74705SXin Li // RUN: not %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
52*67e74705SXin Li // RUN:   -iquote Inputs/merge-target-features \
53*67e74705SXin Li // RUN:   -fno-implicit-modules \
54*67e74705SXin Li // RUN:   -fmodule-map-file-home-is-cwd \
55*67e74705SXin Li // RUN:   -fmodule-map-file=Inputs/merge-target-features/module.modulemap \
56*67e74705SXin Li // RUN:   -fmodule-file=%t/foo.pcm \
57*67e74705SXin Li // RUN:   -triple i386-unknown-unknown \
58*67e74705SXin Li // RUN:   -target-cpu i386 -target-feature +cx16 \
59*67e74705SXin Li // RUN:   -fsyntax-only merge-target-features.cpp 2>&1 \
60*67e74705SXin Li // RUN:   | FileCheck --check-prefix=MISMATCH %s
61*67e74705SXin Li // MISMATCH-NOT: error:
62*67e74705SXin Li // MISMATCH: error: {{.*}} configuration mismatch
63*67e74705SXin Li // MISMATCH-NOT: error:
64*67e74705SXin Li 
65*67e74705SXin Li #include "foo.h"
66*67e74705SXin Li 
test(int x)67*67e74705SXin Li int test(int x) {
68*67e74705SXin Li   return foo(x);
69*67e74705SXin Li }
70