[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / attr-target.c
blob653550757bda768f34d25f987f0680298a7677a2
1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -std=c2x %s
2 // RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify -std=c2x %s
3 // RUN: %clang_cc1 -triple arm-linux-gnu -fsyntax-only -verify -std=c2x %s
5 #ifdef __x86_64__
7 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(void) { return 4; }
8 //expected-error@+1 {{'target' attribute takes one argument}}
9 int __attribute__((target())) bar(void) { return 4; }
10 // no warning, tune is supported for x86
11 int __attribute__((target("tune=sandybridge"))) baz(void) { return 4; }
12 //expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}
13 int __attribute__((target("fpmath=387"))) walrus(void) { return 4; }
14 //expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
15 int __attribute__((target("avx,sse4.2,arch=hiss"))) meow(void) { return 4; }
16 //expected-warning@+1 {{unsupported 'woof' in the 'target' attribute string; 'target' attribute ignored}}
17 int __attribute__((target("woof"))) bark(void) { return 4; }
18 // no warning, same as saying 'nothing'.
19 int __attribute__((target("arch="))) turtle(void) { return 4; }
20 //expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
21 int __attribute__((target("arch=hiss,arch=woof"))) pine_tree(void) { return 4; }
22 //expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}}
23 int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree(void) { return 4; }
24 //expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
25 int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; }
26 //expected-warning@+1 {{unknown tune CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
27 int __attribute__((target("tune=hiss,tune=woof"))) apple_tree(void) { return 4; }
29 #elifdef __aarch64__
31 int __attribute__((target("sve,arch=armv8-a"))) foo(void) { return 4; }
32 //expected-error@+1 {{'target' attribute takes one argument}}
33 int __attribute__((target())) bar(void) { return 4; }
34 // no warning, tune is supported for aarch64
35 int __attribute__((target("tune=cortex-a710"))) baz(void) { return 4; }
36 //expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}
37 int __attribute__((target("fpmath=387"))) walrus(void) { return 4; }
38 //expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
39 int __attribute__((target("sve,cpu=hiss"))) meow(void) { return 4; }
40 // FIXME: We currently have no implementation of isValidFeatureName, so this is not noticed as an error.
41 int __attribute__((target("woof"))) bark(void) { return 4; }
42 // FIXME: Same
43 int __attribute__((target("arch=armv8-a+woof"))) buff(void) { return 4; }
44 // FIXME: Same
45 int __attribute__((target("+noway"))) noway(void) { return 4; }
46 // no warning, same as saying 'nothing'.
47 int __attribute__((target("arch="))) turtle(void) { return 4; }
48 //expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
49 int __attribute__((target("cpu=hiss,cpu=woof"))) pine_tree(void) { return 4; }
50 //expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}}
51 int __attribute__((target("arch=armv8.1-a,arch=armv8-a"))) oak_tree(void) { return 4; }
52 //expected-warning@+1 {{duplicate 'cpu=' in the 'target' attribute string; 'target' attribute ignored}}
53 int __attribute__((target("cpu=cortex-a710,cpu=neoverse-n2"))) apple_tree(void) { return 4; }
54 //expected-warning@+1 {{duplicate 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
55 int __attribute__((target("tune=cortex-a710,tune=neoverse-n2"))) pear_tree(void) { return 4; }
56 // no warning - branch-protection should work on aarch64
57 int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; }
59 #else
61 // tune is not supported by other targets.
62 //expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
63 int __attribute__((target("tune=hiss"))) baz(void) { return 4; }
65 #endif