[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / clang / test / Sema / builtin-cpu-supports.c
blob4dace25b42a97087f36efe3136ae1ffe33ae1831
1 // RUN: %clang_cc1 -fsyntax-only -triple x86_64-pc-linux-gnu -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -triple aarch64-linux-gnu -verify %s
3 // RUN: %clang_cc1 -fsyntax-only -triple riscv32-linux-gnu -verify %s
4 // RUN: %clang_cc1 -fsyntax-only -triple riscv64-linux-gnu -verify %s
5 // RUN: %clang_cc1 -fsyntax-only -triple powerpc64le-unknown-linux -verify %s
6 // RUN: %clang_cc1 -fsyntax-only -triple powerpc64-unknown-aix7.2.0.0 -verify %s
7 // RUN: %clang_cc1 -fsyntax-only -triple powerpc-unknown-aix7.2.0.0 -verify %s
9 extern void a(const char *);
11 extern const char *str;
13 int main(void) {
14 #ifdef __x86_64__
15 if (__builtin_cpu_supports("ss")) // expected-warning {{invalid cpu feature string}}
16 a("sse4.2");
18 if (__builtin_cpu_supports(str)) // expected-error {{expression is not a string literal}}
19 a(str);
21 if (__builtin_cpu_is("int")) // expected-error {{invalid cpu name for builtin}}
22 a("intel");
24 (void)__builtin_cpu_is("x86-64"); // expected-error {{invalid cpu name for builtin}}
25 (void)__builtin_cpu_is("x86-64-v2"); // expected-error {{invalid cpu name for builtin}}
26 (void)__builtin_cpu_is("x86-64-v3"); // expected-error {{invalid cpu name for builtin}}
27 (void)__builtin_cpu_is("x86-64-v4"); // expected-error {{invalid cpu name for builtin}}
29 (void)__builtin_cpu_supports("x86-64");
30 (void)__builtin_cpu_supports("x86-64-v2");
31 (void)__builtin_cpu_supports("x86-64-v3");
32 (void)__builtin_cpu_supports("x86-64-v4");
33 (void)__builtin_cpu_supports("x86-64-v5"); // expected-warning {{invalid cpu feature string for builtin}}
34 #endif
36 #ifdef __aarch64__
37 if (__builtin_cpu_supports("neon")) // expected-warning {{invalid cpu feature string for builtin}}
38 a("vsx");
40 if (__builtin_cpu_is("cortex-x3")) // expected-error {{builtin is not supported on this target}}
41 a("pwr9");
43 __builtin_cpu_init(); // expected-error {{builtin is not supported on this target}}
44 #endif
46 #ifdef __riscv
47 if (__builtin_cpu_supports("garbage")) // expected-warning {{invalid cpu feature string for builtin}}
48 a("vsx");
49 #endif
51 #ifdef __powerpc__
52 if (__builtin_cpu_is("garbage")) // expected-error {{invalid cpu name for builtin}}
53 a("vsx");
55 if (__builtin_cpu_is("power3")) // expected-error {{invalid cpu name for builtin}}
56 a("vsx");
58 if (__builtin_cpu_supports("garbage")) // expected-warning {{invalid cpu feature string for builtin}}
59 a("vsx");
60 #endif
62 return 0;