1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++14
3 // expected-error@+1{{invalid option 'invalid' for cpu_dispatch}}
4 void __attribute__((cpu_dispatch(atom
, invalid
))) invalid_cpu();
6 void __attribute__((cpu_specific(atom
))) no_default(void);
7 void __attribute__((cpu_specific(sandybridge
))) no_default(void);
10 int __attribute__((cpu_specific(sandybridge
))) bar(void);
11 int __attribute__((cpu_specific(ivybridge
))) bar(void);
12 int __attribute__((cpu_specific(sandybridge
))) foo(void);
16 // OK, will fail in the linker, unless another TU provides the cpu_dispatch.
19 // expected-error@+1 {{call to non-static member function without an object argument}}
21 // expected-error@+1 {{call to non-static member function without an object argument}}
23 // expected-error@+1 {{reference to multiversioned function could not be resolved; did you mean to call it?}}
25 // expected-error@+1 {{reference to multiversioned function could not be resolved; did you mean to call it?}}
29 //expected-error@+1 {{attribute 'cpu_specific' multiversioned functions do not yet support constexpr functions}}
30 constexpr int __attribute__((cpu_specific(sandybridge
))) foo(void);
32 int __attribute__((cpu_specific(sandybridge
))) foo2(void);
33 //expected-error@+1 {{attribute 'cpu_specific' multiversioned functions do not yet support constexpr functions}}
34 constexpr int __attribute__((cpu_specific(ivybridge
))) foo2(void);
36 static int __attribute__((cpu_specific(sandybridge
))) bar(void);
37 //expected-error@+1 {{multiversioned function declaration has a different linkage}}
38 int __attribute__((cpu_dispatch(ivybridge
))) bar(void) {}
41 extern int __attribute__((cpu_specific(sandybridge
))) bar2(void);
42 int __attribute__((cpu_dispatch(ivybridge
))) bar2(void) {}
45 int __attribute__((cpu_specific(sandybridge
))) bar3(void);
46 static int __attribute__((cpu_dispatch(ivybridge
))) bar3(void) {}
50 inline int __attribute__((cpu_specific(sandybridge
))) baz(void);
51 //expected-error@+1 {{multiversioned function declaration has a different inline specification}}
52 int __attribute__((cpu_specific(ivybridge
))) baz(void) {return 1;}
54 void __attribute__((cpu_specific(atom
))) diff_return(void);
55 //expected-error@+1 {{multiversioned function declaration has a different return type}}
56 int __attribute__((cpu_specific(sandybridge
))) diff_return(void);
58 int __attribute__((cpu_specific(atom
))) diff_noexcept(void) noexcept(true);
59 //expected-error@+2 {{exception specification in declaration does not match previous declaration}}
60 //expected-note@-2 {{previous declaration is here}}
61 int __attribute__((cpu_specific(sandybridge
))) diff_noexcept(void) noexcept(false);
63 // FIXME: Add support for templates and virtual functions!
64 // expected-error@+2 {{multiversioned functions do not yet support function templates}}
66 int __attribute__((cpu_specific(atom
))) foo(T
) { return 0; }
67 // expected-error@+2 {{multiversioned functions do not yet support function templates}}
69 int __attribute__((cpu_specific(sandybridge
))) foo2(T
);
72 // expected-error@+2 {{multiversioned functions do not yet support function templates}}
74 int __attribute__((cpu_specific(atom
))) foo(T
) { return 0; }
76 // expected-error@+2 {{multiversioned functions do not yet support function templates}}
78 int __attribute__((cpu_dispatch(ivybridge
))) foo2(T
) {}
80 // expected-error@+1 {{multiversioned functions do not yet support virtual functions}}
81 virtual void __attribute__((cpu_specific(atom
))) virt();
85 int __attribute__((cpu_specific(atom
))) diff_mangle(void) { return 0; }
87 //expected-error@+1 {{multiversioned function declaration has a different language linkage}}
88 int __attribute__((cpu_specific(sandybridge
))) diff_mangle(void) { return 0; }
90 __attribute__((cpu_specific(atom
))) void DiffDecl();
93 // expected-error@+3 {{declaration conflicts with target of using declaration already in scope}}
94 // expected-note@-4 {{target of using declaration}}
95 // expected-note@-3 {{using declaration}}
96 __attribute__((cpu_dispatch(atom
))) void DiffDecl();
100 // expected-error@+1 {{multiversioned functions do not yet support constructors}}
101 __attribute__((cpu_specific(atom
))) SpecialFuncs();
102 // expected-error@+1 {{multiversioned functions do not yet support destructors}}
103 __attribute__((cpu_specific(atom
))) ~SpecialFuncs();
105 // expected-error@+1 {{multiversioned functions do not yet support defaulted functions}}
106 SpecialFuncs
& __attribute__((cpu_specific(atom
))) operator=(const SpecialFuncs
&) = default;
107 // expected-error@+1 {{multiversioned functions do not yet support deleted functions}}
108 SpecialFuncs
& __attribute__((cpu_specific(atom
))) operator=(SpecialFuncs
&&) = delete;
112 int __attribute__((cpu_specific(atom
, ivybridge
))) foo(int);
115 int __attribute__((cpu_specific(atom
, ivybridge
))) OutOfLine::foo(int) { return 0; }
116 int __attribute__((cpu_specific(sandybridge
))) OutOfLine::foo(int) { return 1; }
118 // Ensure Cpp Spelling works.
119 [[clang::cpu_specific(ivybridge
,atom
)]] int CppSpelling(){}
121 // expected-error@+1 {{lambda cannot be declared 'cpu_dispatch'}}
122 auto x
= []() __attribute__((cpu_dispatch(atom
))) {};