| 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 |
| 8 |
|
| 9 |
extern void a(const char *); |
| 10 |
|
| 11 |
extern const char *str; |
| 12 |
|
| 13 |
int main(void) { |
| 14 |
#ifdef __x86_64__ |
| 15 |
if (__builtin_cpu_supports("ss")) // expected-warning {{invalid cpu feature string}} |
| 16 |
a("sse4.2"); |
| 17 |
|
| 18 |
if (__builtin_cpu_supports(str)) // expected-error {{expression is not a string literal}} |
| 19 |
a(str); |
| 20 |
|
| 21 |
if (__builtin_cpu_is("int")) // expected-error {{invalid cpu name for builtin}} |
| 22 |
a("intel"); |
| 23 |
|
| 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}} |
| 28 |
|
| 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 |
| 35 |
|
| 36 |
#ifdef __aarch64__ |
| 37 |
if (__builtin_cpu_supports("neon")) // expected-warning {{invalid cpu feature string for builtin}} |
| 38 |
a("vsx"); |
| 39 |
|
| 40 |
if (__builtin_cpu_is("cortex-x3")) // expected-error {{builtin is not supported on this target}} |
| 41 |
a("pwr9"); |
| 42 |
|
| 43 |
__builtin_cpu_init(); // expected-error {{builtin is not supported on this target}} |
| 44 |
#endif |
| 45 |
|
| 46 |
#ifdef __riscv |
| 47 |
if (__builtin_cpu_supports("garbage")) // expected-warning {{invalid cpu feature string for builtin}} |
| 48 |
a("vsx"); |
| 49 |
#endif |
| 50 |
|
| 51 |
#ifdef __powerpc__ |
| 52 |
if (__builtin_cpu_is("garbage")) // expected-error {{invalid cpu name for builtin}} |
| 53 |
a("vsx"); |
| 54 |
|
| 55 |
if (__builtin_cpu_is("power3")) // expected-error {{invalid cpu name for builtin}} |
| 56 |
a("vsx"); |
| 57 |
|
| 58 |
if (__builtin_cpu_supports("garbage")) // expected-warning {{invalid cpu feature string for builtin}} |
| 59 |
a("vsx"); |
| 60 |
#endif |
| 61 |
|
| 62 |
return 0; |
| 63 |
} |