[RISCV][FMV] Support target_clones (#85786)
[llvm-project.git] / clang / test / SemaCXX / attr-target-clones-riscv.cpp
blob4425dd2108a6e064e1c79020c4fe779cd3727de2
1 // RUN: %clang_cc1 -triple riscv64-linux-gnu -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++14
3 // expected-warning@+1 {{unsupported 'mcpu=sifive-u74' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
4 void __attribute__((target_clones("default", "mcpu=sifive-u74"))) mcpu() {}
6 // expected-warning@+1 {{unsupported 'mtune=sifive-u74' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
7 void __attribute__((target_clones("default", "mtune=sifive-u74"))) mtune() {}
9 // expected-warning@+1 {{version list contains duplicate entries}}
10 void __attribute__((target_clones("default", "arch=+c", "arch=+c"))) dupVersion() {}
12 // expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
13 void __attribute__((target_clones("default", ""))) emptyVersion() {}
15 // expected-error@+1 {{'target_clones' multiversioning requires a default target}}
16 void __attribute__((target_clones("arch=+c"))) withoutDefault() {}
18 // expected-warning@+1 {{unsupported '+c' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
19 void __attribute__((target_clones("default", "+c"))) invaildVersion() {}
21 // expected-warning@+1 {{unsupported 'arch=rv64g' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
22 void __attribute__((target_clones("default", "arch=rv64g"))) fullArchString() {}
24 // expected-warning@+1 {{unsupported 'arch=+zicsr' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
25 void __attribute__((target_clones("default", "arch=+zicsr"))) UnsupportBitMaskExt() {}
27 // expected-warning@+1 {{unsupported 'arch=+c;priority=NotADigit' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
28 void __attribute__((target_clones("default", "arch=+c;priority=NotADigit"))) UnsupportPriority() {}
30 // expected-warning@+1 {{unsupported 'default;priority=2' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
31 void __attribute__((target_clones("default;priority=2", "arch=+c"))) UnsupportDefaultPriority() {}
33 // expected-warning@+1 {{unsupported 'priority=2;default' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
34 void __attribute__((target_clones("priority=2;default", "arch=+c"))) UnsupportDefaultPriority2() {}
36 // expected-warning@+1 {{unsupported 'arch=+c,zbb' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
37 void __attribute__((target_clones("default", "arch=+c,zbb"))) WithoutAddSign() {}
40 void lambda() {
41 // expected-error@+1 {{attribute 'target_clones' multiversioned functions do not yet support lambdas}}
42 auto x = []() __attribute__((target_clones("default"))){};
43 x();
44 // expected-error@+1 {{attribute 'target_clones' multiversioned functions do not yet support lambdas}}
45 auto y = []() __attribute__((target_clones("arch=+v", "default"))){};
46 y();