xref: /llvm-project/clang/test/SemaCXX/attr-target-version-riscv.cpp (revision c77e836123d056d98051ee980003593706f9284d)
1 // RUN: %clang_cc1 -triple riscv64-linux-gnu  -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++14
2 
3 // expected-warning@+2 {{unsupported 'arch=rv64gcv' in the 'target_version' attribute string; 'target_version' attribute ignored}}
4 // expected-note@+1 {{previous definition is here}}
5 __attribute__((target_version("arch=rv64gcv"))) int fullArchString(void) { return 2; }
6 // expected-error@+2 {{redefinition of 'fullArchString'}}
7 // expected-warning@+1 {{unsupported 'arch=default' in the 'target_version' attribute string; 'target_version' attribute ignored}}
8 __attribute__((target_version("arch=default"))) int fullArchString(void) { return 2; }
9 
10 // expected-warning@+2 {{unsupported 'mcpu=sifive-u74' in the 'target_version' attribute string; 'target_version' attribute ignored}}
11 // expected-note@+1 {{previous definition is here}}
12 __attribute__((target_version("mcpu=sifive-u74"))) int mcpu(void) { return 2; }
13 // expected-error@+1 {{redefinition of 'mcpu'}}
14 __attribute__((target_version("default"))) int mcpu(void) { return 2; }
15 
16 // expected-warning@+2 {{unsupported 'mtune=sifive-u74' in the 'target_version' attribute string; 'target_version' attribute ignored}}
17 // expected-note@+1 {{previous definition is here}}
18 __attribute__((target_version("mtune=sifive-u74"))) int mtune(void) { return 2; }
19 // expected-error@+1 {{redefinition of 'mtune'}}
20 __attribute__((target_version("default"))) int mtune(void) { return 2; }
21 
22 // expected-warning@+2 {{unsupported '' in the 'target_version' attribute string; 'target_version' attribute ignored}}
23 // expected-note@+1 {{previous definition is here}}
24 __attribute__((target_version(""))) int emptyVersion(void) { return 2; }
25 // expected-error@+1 {{redefinition of 'emptyVersion'}}
26 __attribute__((target_version("default"))) int emptyVersion(void) { return 2; }
27 
28 // expected-note@+1 {{previous definition is here}}
29 __attribute__((target_version("arch=+c"))) int dupVersion(void) { return 2; }
30 // expected-error@+1 {{redefinition of 'dupVersion'}}
31 __attribute__((target_version("arch=+c"))) int dupVersion(void) { return 2; }
32 __attribute__((target_version("default"))) int dupVersion(void) { return 2; }
33 
34 // expected-warning@+2 {{unsupported 'arch=+zicsr' in the 'target_version' attribute string; 'target_version' attribute ignored}}
35 // expected-note@+1 {{previous definition is here}}
36 __attribute__((target_version("arch=+zicsr"))) int UnsupportBitMaskExt(void) { return 2; }
37 // expected-error@+1 {{redefinition of 'UnsupportBitMaskExt'}}
38 __attribute__((target_version("default"))) int UnsupportBitMaskExt(void) { return 2; }
39 
40 // expected-warning@+2 {{unsupported 'NotADigit' in the 'target_version' attribute string; 'target_version' attribute ignored}}
41 // expected-note@+1 {{previous definition is here}}
42 __attribute__((target_version("arch=+c;priority=NotADigit"))) int UnsupportPriority(void) { return 2; }
43 // expected-error@+1 {{redefinition of 'UnsupportPriority'}}
44 __attribute__((target_version("default"))) int UnsupportPriority(void) { return 2;}
45 
46 // expected-warning@+1 {{unsupported 'default;priority=2' in the 'target_version' attribute string; 'target_version' attribute ignored}}
47 __attribute__((target_version("default;priority=2"))) int UnsupportDefaultPriority(void) { return 2; }
48 
49 // expected-warning@+2 {{unsupported 'arch=+c,zbb' in the 'target_version' attribute string; 'target_version' attribute ignored}}
50 // expected-note@+1 {{previous definition is here}}
51 __attribute__((target_version("arch=+c,zbb"))) int WithoutAddSign(void) { return 2;}
52 // expected-error@+1 {{redefinition of 'WithoutAddSign'}}
53 __attribute__((target_version("default"))) int WithoutAddSign(void) { return 2; }
54 
55 // expected-warning@+2 {{unsupported 'arch=+c;default' in the 'target_version' attribute string; 'target_version' attribute ignored}}
56 // expected-note@+1 {{previous definition is here}}
57 __attribute__((target_version("arch=+c;default"))) int DefaultInVersion(void) { return 2;}
58 // expected-error@+1 {{redefinition of 'DefaultInVersion'}}
59 __attribute__((target_version("default"))) int DefaultInVersion(void) { return 2; }
60 
61 // expected-warning@+2 {{unsupported '' in the 'target_version' attribute string; 'target_version' attribute ignored}}
62 // expected-note@+1 {{previous definition is here}}
63 __attribute__((target_version("arch=+c;"))) int EmptyVersionAfterSemiColon(void) { return 2;}
64 // expected-error@+1 {{redefinition of 'EmptyVersionAfterSemiColon'}}
65 __attribute__((target_version("default"))) int EmptyVersionAfterSemiColon(void) { return 2; }
66 
67 // expected-warning@+2 {{unsupported 'arch=+c;arch=+f' in the 'target_version' attribute string; 'target_version' attribute ignored}}
68 // expected-note@+1 {{previous definition is here}}
69 __attribute__((target_version("arch=+c;arch=+f"))) int dupArch(void) { return 2; }
70 // expected-error@+1 {{redefinition of 'dupArch'}}
71 __attribute__((target_version("default"))) int dupArch(void) { return 2; }
72 
73 // expected-warning@+2 {{unsupported 'default;default' in the 'target_version' attribute string; 'target_version' attribute ignored}}
74 // expected-note@+1 {{previous definition is here}}
75 __attribute__((target_version("default;default"))) int dupDefault(void) { return 2;}
76 // expected-error@+1 {{redefinition of 'dupDefault'}}
77 __attribute__((target_version("default"))) int dupDefault(void) { return 2; }
78 
79 // expected-warning@+2 {{unsupported 'priority=1;priority=2' in the 'target_version' attribute string; 'target_version' attribute ignored}}
80 // expected-note@+1 {{previous definition is here}}
81 __attribute__((target_version("priority=1;priority=2"))) int dupPriority(void) { return 2; }
82 // expected-error@+1 {{redefinition of 'dupPriority'}}
83 __attribute__((target_version("default"))) int dupPriority(void) { return 2; }
84 
85 // expected-warning@+2 {{unsupported '=1' in the 'target_version' attribute string; 'target_version' attribute ignored}}
86 // expected-note@+1 {{previous definition is here}}
87 __attribute__((target_version("=1"))) int invalidVerson1(void) { return 2; }
88 // expected-error@+1 {{redefinition of 'invalidVerson1'}}
89 __attribute__((target_version("default"))) int invalidVerson1(void) { return 2; }
90 
91 // expected-warning@+2 {{unsupported '=+v' in the 'target_version' attribute string; 'target_version' attribute ignored}}
92 // expected-note@+1 {{previous definition is here}}
93 __attribute__((target_version("=+v"))) int invalidVerson2(void) { return 2; }
94 // expected-error@+1 {{redefinition of 'invalidVerson2'}}
95 __attribute__((target_version("default"))) int invalidVerson2(void) { return 2; }
96 
97 // expected-warning@+2 {{unsupported 'v' in the 'target_version' attribute string; 'target_version' attribute ignored}}
98 // expected-note@+1 {{previous definition is here}}
99 __attribute__((target_version("v"))) int invalidVerson3(void) { return 2; }
100 // expected-error@+1 {{redefinition of 'invalidVerson3'}}
101 __attribute__((target_version("default"))) int invalidVerson3(void) { return 2; }
102 
103 // expected-warning@+2 {{unsupported '' in the 'target_version' attribute string; 'target_version' attribute ignored}}
104 // expected-note@+1 {{previous definition is here}}
105 __attribute__((target_version(";"))) int invalidVerson4(void) { return 2; }
106 // expected-error@+1 {{redefinition of 'invalidVerson4'}}
107 __attribute__((target_version("default"))) int invalidVerson4(void) { return 2; }
108 
109 // expected-warning@+2 {{unsupported 'priority=1' in the 'target_version' attribute string; 'target_version' attribute ignored}}
110 // expected-note@+1 {{previous definition is here}}
111 __attribute__((target_version("priority=1"))) int prioriyWithoutArch(void) { return 2; }
112 // expected-error@+1 {{redefinition of 'prioriyWithoutArch'}}
113 __attribute__((target_version("default"))) int prioriyWithoutArch(void) { return 2; }
114 
115 // expected-warning@+2 {{unsupported '-1' in the 'target_version' attribute string; 'target_version' attribute ignored}}
116 // expected-note@+1 {{previous definition is here}}
117 __attribute__((target_version("arch=+c;priority=-1"))) int UnsupportNegativePriority(void) { return 2; }
118 // expected-error@+1 {{redefinition of 'UnsupportNegativePriority'}}
119 __attribute__((target_version("default"))) int UnsupportNegativePriority(void) { return 2; }
120