[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / attr-target.c
blob4318183e0e3ce3e9cc115244d59b272f8fb66485
1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify %s
4 #ifdef __x86_64__
6 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(void) { return 4; }
7 //expected-error@+1 {{'target' attribute takes one argument}}
8 int __attribute__((target())) bar(void) { return 4; }
9 // no warning, tune is supported for x86
10 int __attribute__((target("tune=sandybridge"))) baz(void) { return 4; }
11 //expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}
12 int __attribute__((target("fpmath=387"))) walrus(void) { return 4; }
13 //expected-warning@+1 {{unknown architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
14 int __attribute__((target("avx,sse4.2,arch=hiss"))) meow(void) { return 4; }
15 //expected-warning@+1 {{unsupported 'woof' in the 'target' attribute string; 'target' attribute ignored}}
16 int __attribute__((target("woof"))) bark(void) { return 4; }
17 // no warning, same as saying 'nothing'.
18 int __attribute__((target("arch="))) turtle(void) { return 4; }
19 //expected-warning@+1 {{unknown architecture 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
20 int __attribute__((target("arch=hiss,arch=woof"))) pine_tree(void) { return 4; }
21 //expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}}
22 int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree(void) { return 4; }
23 //expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
24 int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; }
25 //expected-warning@+1 {{unknown tune CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
26 int __attribute__((target("tune=hiss,tune=woof"))) apple_tree(void) { return 4; }
28 #else
30 // tune is not supported by other targets.
31 //expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
32 int __attribute__((target("tune=hiss"))) baz(void) { return 4; }
34 #endif