1 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -DTEST1
2 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -DTEST2
3 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -DTEST3
4 
5 struct S {
6   __attribute__((always_inline, target("avx512f")))
7   void foo(){}
8   __attribute__((always_inline, target("avx512f")))
9   operator int(){ return 0; }
10   __attribute__((always_inline, target("avx512f")))
11   void operator()(){ }
12 
13 };
14 __attribute__((always_inline, target("avx512f")))
15 void free_func(){}
16 
17 
18 #ifdef TEST1
19 void usage(S & s) {
20   s.foo(); // expected-error {{'foo' requires target feature 'avx512f'}}
21   (void)(int)s; // expected-error {{'operator int' requires target feature 'avx512f'}}
22   s(); // expected-error {{'operator()' requires target feature 'avx512f'}}
23   free_func(); // expected-error{{'free_func' requires target feature 'avx512f'}}
24 
25 }
26 #endif
27 
28 #ifdef TEST2
29 __attribute__((target("avx512f")))
30 void usage(S & s) {
31   s.foo();
32   (void)(int)s;
33   s();
34 
35   [&s] {
36     s.foo();       // expected-error {{'foo' requires target feature 'avx512f'}}
37     (void)(int) s; // expected-error {{'operator int' requires target feature 'avx512f'}}
38     s();           // expected-error {{'operator()' requires target feature 'avx512f'}}
39     free_func();   // expected-error{{'free_func' requires target feature 'avx512f'}}
40   }();
41 }
42 #endif
43 
44 #ifdef TEST3
45 void usage(S & s) {
46 
47   [&s] () __attribute__((target("avx512f"))) {
48     s.foo();
49     (void)(int) s;
50     s();
51     free_func();
52   }();
53 
54   [&s] {
55     s.foo();       // expected-error {{'foo' requires target feature 'avx512f'}}
56     (void)(int) s; // expected-error {{'operator int' requires target feature 'avx512f'}}
57     s();           // expected-error {{'operator()' requires target feature 'avx512f'}}
58     free_func();   // expected-error{{'free_func' requires target feature 'avx512f'}}
59   }();
60 }
61 #endif
62