[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / attr-target.c
blob5328f056507a7140109c6881ba43565caec1ee95
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
4 // RUN: %clang_cc1 -triple powerpc-linux-gnu -fsyntax-only -verify -std=c2x %s
5 // RUN: %clang_cc1 -triple ppc64le-linux-gnu -fsyntax-only -verify -std=c2x %s
7 #ifdef __x86_64__
9 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(void) { return 4; }
10 //expected-error@+1 {{'target' attribute takes one argument}}
11 int __attribute__((target())) bar(void) { return 4; }
12 // no warning, tune is supported for x86
13 int __attribute__((target("tune=sandybridge"))) baz(void) { return 4; }
14 //expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}
15 int __attribute__((target("fpmath=387"))) walrus(void) { return 4; }
16 //expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
17 int __attribute__((target("avx,sse4.2,arch=hiss"))) meow(void) { return 4; }
18 //expected-warning@+1 {{unsupported 'woof' in the 'target' attribute string; 'target' attribute ignored}}
19 int __attribute__((target("woof"))) bark(void) { return 4; }
20 // no warning, same as saying 'nothing'.
21 int __attribute__((target("arch="))) turtle(void) { return 4; }
22 //expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
23 int __attribute__((target("arch=hiss,arch=woof"))) pine_tree(void) { return 4; }
24 //expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}}
25 int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree(void) { return 4; }
26 //expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
27 int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; }
28 //expected-warning@+1 {{unknown tune CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
29 int __attribute__((target("tune=hiss,tune=woof"))) apple_tree(void) { return 4; }
31 //expected-warning@+1 {{unsupported 'x86-64' in the 'target' attribute string}}
32 void __attribute__((target("x86-64"))) baseline(void) {}
33 //expected-warning@+1 {{unsupported 'x86-64-v2' in the 'target' attribute string}}
34 void __attribute__((target("x86-64-v2"))) v2(void) {}
36 #elifdef __aarch64__
38 int __attribute__((target("sve,arch=armv8-a"))) foo(void) { return 4; }
39 //expected-error@+1 {{'target' attribute takes one argument}}
40 int __attribute__((target())) bar(void) { return 4; }
41 // no warning, tune is supported for aarch64
42 int __attribute__((target("tune=cortex-a710"))) baz(void) { return 4; }
43 //expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}
44 int __attribute__((target("fpmath=387"))) walrus(void) { return 4; }
45 //expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
46 int __attribute__((target("sve,cpu=hiss"))) meow(void) { return 4; }
47 // FIXME: We currently have no implementation of isValidFeatureName, so this is not noticed as an error.
48 int __attribute__((target("woof"))) bark(void) { return 4; }
49 // FIXME: Same
50 int __attribute__((target("arch=armv8-a+woof"))) buff(void) { return 4; }
51 // FIXME: Same
52 int __attribute__((target("+noway"))) noway(void) { return 4; }
53 // no warning, same as saying 'nothing'.
54 int __attribute__((target("arch="))) turtle(void) { return 4; }
55 //expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
56 int __attribute__((target("cpu=hiss,cpu=woof"))) pine_tree(void) { return 4; }
57 //expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}}
58 int __attribute__((target("arch=armv8.1-a,arch=armv8-a"))) oak_tree(void) { return 4; }
59 //expected-warning@+1 {{duplicate 'cpu=' in the 'target' attribute string; 'target' attribute ignored}}
60 int __attribute__((target("cpu=cortex-a710,cpu=neoverse-n2"))) apple_tree(void) { return 4; }
61 //expected-warning@+1 {{duplicate 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
62 int __attribute__((target("tune=cortex-a710,tune=neoverse-n2"))) pear_tree(void) { return 4; }
63 // no warning - branch-protection should work on aarch64
64 int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; }
66 #elifdef __powerpc__
68 int __attribute__((target("float128,arch=pwr9"))) foo(void) { return 4; }
69 //expected-error@+1 {{'target' attribute takes one argument}}
70 int __attribute__((target())) bar(void) { return 4; }
71 // no warning, tune is supported for PPC
72 int __attribute__((target("tune=pwr8"))) baz(void) { return 4; }
73 //expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}
74 int __attribute__((target("fpmath=387"))) walrus(void) { return 4; }
75 //expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
76 int __attribute__((target("float128,arch=hiss"))) meow(void) { return 4; }
77 // no warning, same as saying 'nothing'.
78 int __attribute__((target("arch="))) turtle(void) { return 4; }
79 //expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
80 int __attribute__((target("arch=hiss,arch=woof"))) pine_tree(void) { return 4; }
81 //expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}}
82 int __attribute__((target("arch=pwr9,arch=pwr10"))) oak_tree(void) { return 4; }
83 //expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
84 int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; }
85 //expected-warning@+1 {{unknown tune CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
86 int __attribute__((target("tune=hiss,tune=woof"))) apple_tree(void) { return 4; }
88 #else
90 // tune is not supported by other targets.
91 //expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
92 int __attribute__((target("tune=hiss"))) baz(void) { return 4; }
94 #endif