Clang Project

clang_source_code/test/Sema/builtin-cpu-supports.c
1// RUN: %clang_cc1 -fsyntax-only -triple x86_64-pc-linux-gnu -verify %s
2// RUN: %clang_cc1 -fsyntax-only -triple powerpc64le-linux-gnu -verify %s
3
4extern void a(const char *);
5
6extern const char *str;
7
8int main() {
9#ifdef __x86_64__
10  if (__builtin_cpu_supports("ss")) // expected-error {{invalid cpu feature string}}
11    a("sse4.2");
12
13  if (__builtin_cpu_supports(str)) // expected-error {{expression is not a string literal}}
14    a(str);
15
16  if (__builtin_cpu_is("int")) // expected-error {{invalid cpu name for builtin}}
17    a("intel");
18#else
19  if (__builtin_cpu_supports("vsx")) // expected-error {{use of unknown builtin}}
20    a("vsx");
21
22  if (__builtin_cpu_is("pwr9")) // expected-error {{use of unknown builtin}}
23    a("pwr9");
24#endif
25
26  return 0;
27}
28