1 // RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify %s
3 int __attribute__((target_version("crc"))) dup(void) { return 3; }
4 int __attribute__((target_version("default"))) dup(void) { return 1; }
5 //expected-error@+2 {{redefinition of 'dup'}}
6 //expected-note@-2 {{previous definition is here}}
7 int __attribute__((target_version("default"))) dup(void) { return 2; }
9 int __attribute__((target_version("default"))) dup1(void) { return 1; }
10 //expected-error@+2 {{redefinition of 'dup1'}}
11 //expected-note@-2 {{previous definition is here}}
12 int dup1(void) { return 2; }
14 int __attribute__((target_version("aes"))) foo(void) { return 1; }
15 //expected-note@+1 {{previous definition is here}}
16 int __attribute__((target_version("default"))) foo(void) { return 2; }
18 //expected-note@+1 {{previous definition is here}}
19 int __attribute__((target_version("sha3 + pmull "))) foo(void) { return 1; }
20 //expected-note@-1 {{previous definition is here}}
22 //expected-error@+1 {{redefinition of 'foo'}}
23 int __attribute__((target("dotprod"))) foo(void) { return -1; }
24 //expected-warning@-1 {{attribute declaration must precede definition}}
26 //expected-error@+1 {{redefinition of 'foo'}}
27 int foo(void) { return 2; }
29 //expected-note@+1 {{previous definition is here}}
30 __attribute__ ((target("bf16,sve,sve2,dotprod"))) int func(void) { return 1; }
31 //expected-error@+1 {{redefinition of 'func'}}
32 __attribute__ ((target("default"))) int func(void) { return 0; }
34 //expected-note@+1 {{previous declaration is here}}
35 void __attribute__((target_version("bti+flagm2"))) one(void) {}
36 //expected-error@+1 {{multiversioned function redeclarations require identical target attributes}}
37 void __attribute__((target_version("flagm2+bti"))) one(void) {}
39 void __attribute__((target_version("ssbs+sha1"))) two(void) {}
40 void __attribute__((target_version("ssbs+fp16fml"))) two(void) {}
42 //expected-error@+1 {{'main' cannot be a multiversioned function}}
43 int __attribute__((target_version("lse"))) main(void) { return 1; }
45 //expected-note@+1 {{previous definition is here}}
46 int hoo(void) { return 1; }
47 //expected-note@-1 {{previous definition is here}}
48 //expected-warning@+2 {{attribute declaration must precede definition}}
49 //expected-error@+1 {{redefinition of 'hoo'}}
50 int __attribute__((target_version("dit"))) hoo(void) { return 2; }
52 //expected-warning@+1 {{unsupported '' in the 'target_version' attribute string; 'target_version' attribute ignored}}
53 int __attribute__((target_version(""))) unsup1(void) { return 1; }
54 //expected-warning@+1 {{unsupported 'crc32' in the 'target_version' attribute string; 'target_version' attribute ignored}}
55 void __attribute__((target_version("crc32"))) unsup2(void) {}
57 void __attribute__((target_version("default+fp16"))) koo(void) {}
58 void __attribute__((target_version("default+default+default"))) loo(void) {}
59 void __attribute__((target_version("rdm+rng+crc"))) redef(void) {}
60 //expected-error@+2 {{redefinition of 'redef'}}
61 //expected-note@-2 {{previous definition is here}}
62 void __attribute__((target_version("rdm+rng+crc"))) redef(void) {}
64 int __attribute__((target_version("sm4"))) def(void);
65 void __attribute__((target_version("dit"))) nodef(void);
66 void __attribute__((target_version("ls64"))) nodef(void);
67 void __attribute__((target_version("aes"))) ovl(void);
68 void __attribute__((target_version("default"))) ovl(void);
70 // expected-error@+2 {{reference to overloaded function could not be resolved; did you mean to call it?}}
71 // expected-note@-3 {{possible target for call}}
73 // expected-error@+1 {{no matching function for call to 'nodef'}}
77 // expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
78 int __attribute__((target_version("sha1"))) def(void) { return 1; }
80 int __attribute__((target_version("sve"))) prot();
81 // expected-error@-1 {{multiversioned function must have a prototype}}
82 // expected-note@+1 {{function multiversioning caused by this declaration}}
83 int __attribute__((target_version("fcma"))) prot();
85 int __attribute__((target_version("pmull"))) rtype(int);
86 // expected-error@+1 {{multiversioned function declaration has a different return type}}
87 float __attribute__((target_version("rdm"))) rtype(int);
89 int __attribute__((target_version("sha2"))) combine(void) { return 1; }
90 // expected-error@+1 {{multiversioned function declaration has a different calling convention}}
91 int __attribute__((aarch64_vector_pcs
, target_version("sha3"))) combine(void) { return 2; }
93 int __attribute__((target_version("fp+aes+pmull+rcpc"))) unspec_args() { return -1; }
94 // expected-error@+1 {{multiversioned function must have a prototype}}
95 int __attribute__((target_version("default"))) unspec_args() { return 0; }
96 int cargs() { return unspec_args(); }