113 lines · cpp
1// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++142void __attribute__((target_version("default"))) wrong_tv(void);3//expected-warning@+1 {{unsupported 'vmull' in the 'target_version' attribute string; 'target_version' attribute ignored}}4void __attribute__((target_version("vmull"))) wrong_tv(void);5 6void __attribute__((target_version("dotprod"))) no_def(void);7void __attribute__((target_version("rdm+fp"))) no_def(void);8void __attribute__((target_version("rcpc3"))) no_def(void);9void __attribute__((target_version("mops"))) no_def(void);10void __attribute__((target_version("rdma"))) no_def(void);11 12void foo(void) { no_def(); }13 14constexpr int __attribute__((target_version("sve2"))) diff_const(void) { return 1; }15//expected-error@+1 {{multiversioned function declaration has a different constexpr specification}}16int __attribute__((target_version("sve2-bitperm"))) diff_const(void);17 18int __attribute__((target_version("fp"))) diff_const1(void) { return 1; }19//expected-error@+1 {{multiversioned function declaration has a different constexpr specification}}20constexpr int __attribute__((target_version("sve2-aes"))) diff_const1(void);21 22static int __attribute__((target_version("sve2-sha3"))) diff_link(void) { return 1; }23//expected-error@+1 {{multiversioned function declaration has a different linkage}}24int __attribute__((target_version("dpb"))) diff_link(void);25 26int __attribute__((target_version("memtag"))) diff_link1(void) { return 1; }27//expected-error@+1 {{multiversioned function declaration has a different linkage}}28static int __attribute__((target_version("bti"))) diff_link1(void);29 30int __attribute__((target_version("flagm2"))) diff_link2(void) { return 1; }31extern int __attribute__((target_version("flagm"))) diff_link2(void);32 33namespace {34static int __attribute__((target_version("memtag"))) diff_link2(void) { return 2; }35int __attribute__((target_version("sve2-bitperm"))) diff_link2(void) { return 1; }36} // namespace37 38inline int __attribute__((target_version("sme"))) diff_inline(void) { return 1; }39//expected-error@+1 {{multiversioned function declaration has a different inline specification}}40int __attribute__((target_version("fp16"))) diff_inline(void) { return 2; }41 42inline int __attribute__((target_version("sme"))) diff_inline1(void) { return 1; }43//expected-error@+1 {{multiversioned function declaration has a different inline specification}}44int __attribute__((target_version("default"))) diff_inline1(void) { return 2; }45 46int __attribute__((target_version("fcma"))) diff_type1(void) { return 1; }47//expected-error@+1 {{multiversioned function declaration has a different return type}}48double __attribute__((target_version("rcpc"))) diff_type1(void);49 50auto __attribute__((target_version("rcpc2"))) diff_type2(void) -> int { return 1; }51//expected-error@+1 {{multiversioned function declaration has a different return type}}52auto __attribute__((target_version("bf16"))) diff_type2(void) -> long { return (long)1; }53 54int __attribute__((target_version("fp16fml"))) diff_type3(void) noexcept(false) { return 1; }55//expected-error@+2 {{exception specification in declaration does not match previous declaration}}56//expected-note@-2 {{previous declaration is here}}57int __attribute__((target_version("sve2-sha3"))) diff_type3(void) noexcept(true) { return 2; }58 59template <typename T> int __attribute__((target_version("default"))) temp(T) { return 1; }60// expected-error@-1 {{attribute 'target_version' multiversioned functions do not yet support function templates}}61template <typename T> int __attribute__((target_version("simd"))) temp1(T) { return 1; }62// expected-error@-1 {{attribute 'target_version' multiversioned functions do not yet support function templates}}63 64extern "C" {65int __attribute__((target_version("aes"))) extc(void) { return 1; }66}67//expected-error@+1 {{multiversioned function declaration has a different language linkage}}68int __attribute__((target_version("lse"))) extc(void) { return 1; }69 70auto __attribute__((target_version("default"))) ret1(void) { return 1; }71// expected-error@-1 {{attribute 'target_version' multiversioned functions do not yet support deduced return types}}72auto __attribute__((target_version("dpb"))) ret2(void) { return 1; }73// expected-error@-1 {{attribute 'target_version' multiversioned functions do not yet support deduced return types}}74auto __attribute__((target_version("dpb2"))) ret3(void) -> int { return 1; }75 76class Cls {77 __attribute__((target_version("rng"))) Cls();78 // expected-error@-1 {{attribute 'target_version' multiversioned functions do not yet support constructors}}79 __attribute__((target_version("i8mm"))) ~Cls();80 // expected-error@-1 {{attribute 'target_version' multiversioned functions do not yet support destructors}}81 82 Cls &__attribute__((target_version("f32mm"))) operator=(const Cls &) = default;83 // expected-error@-1 {{attribute 'target_version' multiversioned functions do not yet support defaulted functions}}84 Cls &__attribute__((target_version("ssbs"))) operator=(Cls &&) = delete;85 // expected-error@-1 {{attribute 'target_version' multiversioned functions do not yet support deleted functions}}86 87 virtual void __attribute__((target_version("default"))) vfunc();88 // expected-error@-1 {{attribute 'target_version' multiversioned functions do not yet support virtual functions}}89 virtual void __attribute__((target_version("sm4"))) vfunc1();90 // expected-error@-1 {{attribute 'target_version' multiversioned functions do not yet support virtual functions}}91};92 93__attribute__((target_version("sha3"))) void Decl();94namespace Nms {95using ::Decl;96// expected-error@+3 {{declaration conflicts with target of using declaration already in scope}}97// expected-note@-4 {{target of using declaration}}98// expected-note@-3 {{using declaration}}99__attribute__((target_version("jscvt"))) void Decl();100} // namespace Nms101 102class Out { // #defined-here103 int __attribute__((target_version("bti"))) func(void);104 int __attribute__((target_version("ssbs"))) func(void);105};106int __attribute__((target_version("bti"))) Out::func(void) { return 1; }107int __attribute__((target_version("ssbs"))) Out::func(void) { return 2; }108// expected-error@+4 {{out-of-line definition of 'func' does not match any declaration in 'Out'}}109// expected-note@-2 {{member declaration nearly matches}}110// expected-note@-4 {{member declaration nearly matches}}111// expected-note@#defined-here {{defined here}}112int __attribute__((target_version("rng"))) Out::func(void) { return 3; }113