1856f3fe5SErich Keane // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -DTEST1
2856f3fe5SErich Keane // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -DTEST2
3856f3fe5SErich Keane // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -DTEST3
4*30588a73SErich Keane // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -DTEST4
536176249SErich Keane 
636176249SErich Keane struct S {
736176249SErich Keane   __attribute__((always_inline, target("avx512f")))
fooS836176249SErich Keane   void foo(){}
936176249SErich Keane   __attribute__((always_inline, target("avx512f")))
operator intS1036176249SErich Keane   operator int(){ return 0; }
1136176249SErich Keane   __attribute__((always_inline, target("avx512f")))
operator ()S1236176249SErich Keane   void operator()(){ }
1336176249SErich Keane 
1436176249SErich Keane };
15856f3fe5SErich Keane __attribute__((always_inline, target("avx512f")))
free_func()16856f3fe5SErich Keane void free_func(){}
1736176249SErich Keane 
18856f3fe5SErich Keane 
19856f3fe5SErich Keane #ifdef TEST1
usage(S & s)2036176249SErich Keane void usage(S & s) {
2136176249SErich Keane   s.foo(); // expected-error {{'foo' requires target feature 'avx512f'}}
2236176249SErich Keane   (void)(int)s; // expected-error {{'operator int' requires target feature 'avx512f'}}
2336176249SErich Keane   s(); // expected-error {{'operator()' requires target feature 'avx512f'}}
24856f3fe5SErich Keane   free_func(); // expected-error{{'free_func' requires target feature 'avx512f'}}
25856f3fe5SErich Keane 
2636176249SErich Keane }
27856f3fe5SErich Keane #endif
28856f3fe5SErich Keane 
29856f3fe5SErich Keane #ifdef TEST2
30856f3fe5SErich Keane __attribute__((target("avx512f")))
usage(S & s)31856f3fe5SErich Keane void usage(S & s) {
32856f3fe5SErich Keane   s.foo();
33856f3fe5SErich Keane   (void)(int)s;
34856f3fe5SErich Keane   s();
35856f3fe5SErich Keane 
36856f3fe5SErich Keane   [&s] {
37856f3fe5SErich Keane     s.foo();       // expected-error {{'foo' requires target feature 'avx512f'}}
38856f3fe5SErich Keane     (void)(int) s; // expected-error {{'operator int' requires target feature 'avx512f'}}
39856f3fe5SErich Keane     s();           // expected-error {{'operator()' requires target feature 'avx512f'}}
40856f3fe5SErich Keane     free_func();   // expected-error{{'free_func' requires target feature 'avx512f'}}
41856f3fe5SErich Keane   }();
42856f3fe5SErich Keane }
43856f3fe5SErich Keane #endif
44856f3fe5SErich Keane 
45856f3fe5SErich Keane #ifdef TEST3
usage(S & s)46856f3fe5SErich Keane void usage(S & s) {
47856f3fe5SErich Keane 
48856f3fe5SErich Keane   [&s] () __attribute__((target("avx512f"))) {
49856f3fe5SErich Keane     s.foo();
50856f3fe5SErich Keane     (void)(int) s;
51856f3fe5SErich Keane     s();
52856f3fe5SErich Keane     free_func();
53856f3fe5SErich Keane   }();
54856f3fe5SErich Keane 
55856f3fe5SErich Keane   [&s] {
56856f3fe5SErich Keane     s.foo();       // expected-error {{'foo' requires target feature 'avx512f'}}
57856f3fe5SErich Keane     (void)(int) s; // expected-error {{'operator int' requires target feature 'avx512f'}}
58856f3fe5SErich Keane     s();           // expected-error {{'operator()' requires target feature 'avx512f'}}
59856f3fe5SErich Keane     free_func();   // expected-error{{'free_func' requires target feature 'avx512f'}}
60856f3fe5SErich Keane   }();
61856f3fe5SErich Keane }
62856f3fe5SErich Keane #endif
63*30588a73SErich Keane 
64*30588a73SErich Keane #ifdef TEST4
65*30588a73SErich Keane namespace PR45468 {
66*30588a73SErich Keane   struct CtorAndDTor {
67*30588a73SErich Keane     __attribute__((always_inline, target("avx512f"))) CtorAndDTor();
68*30588a73SErich Keane     __attribute__((always_inline, target("avx512f"))) ~CtorAndDTor();
69*30588a73SErich Keane   };
70*30588a73SErich Keane 
usage()71*30588a73SErich Keane   void usage() {
72*30588a73SErich Keane     //expected-error@+1{{'CtorAndDTor' requires target feature 'avx512f'}}
73*30588a73SErich Keane     CtorAndDTor c;
74*30588a73SErich Keane     {
75*30588a73SErich Keane       //expected-error@+1{{'CtorAndDTor' requires target feature 'avx512f'}}
76*30588a73SErich Keane       CtorAndDTor c2;
77*30588a73SErich Keane       //expected-error@+1{{'~CtorAndDTor' requires target feature 'avx512f'}}
78*30588a73SErich Keane       c2.~CtorAndDTor();
79*30588a73SErich Keane     }
80*30588a73SErich Keane     // FIXME: These need to be given a line number, however theres no good way
81*30588a73SErich Keane     // to get to the SourceLocation of anything by the time we're doing CodeGen
82*30588a73SErich Keane     // cleanups.
83*30588a73SErich Keane     //expected-error@*{{'~CtorAndDTor' requires target feature 'avx512f'}}
84*30588a73SErich Keane     //expected-error@*{{'~CtorAndDTor' requires target feature 'avx512f'}}
85*30588a73SErich Keane   }
86*30588a73SErich Keane }
87*30588a73SErich Keane #endif
88