Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / target-features-error.cpp
bloba460679f8fa11fabacecec6b8d5bc899e39c0428
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 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -DTEST4
6 struct S {
7 __attribute__((always_inline, target("avx512f")))
8 void foo(){}
9 __attribute__((always_inline, target("avx512f")))
10 operator int(){ return 0; }
11 __attribute__((always_inline, target("avx512f")))
12 void operator()(){ }
15 __attribute__((always_inline, target("avx512f")))
16 void free_func(){}
19 #ifdef TEST1
20 void usage(S & s) {
21 s.foo(); // expected-error {{'foo' requires target feature 'avx512f'}}
22 (void)(int)s; // expected-error {{'operator int' requires target feature 'avx512f'}}
23 s(); // expected-error {{'operator()' requires target feature 'avx512f'}}
24 free_func(); // expected-error{{'free_func' requires target feature 'avx512f'}}
27 #endif
29 #ifdef TEST2
30 __attribute__((target("avx512f")))
31 void usage(S & s) {
32 s.foo();
33 (void)(int)s;
34 s();
36 [&s] {
37 s.foo(); // expected-error {{'foo' requires target feature 'avx512f'}}
38 (void)(int) s; // expected-error {{'operator int' requires target feature 'avx512f'}}
39 s(); // expected-error {{'operator()' requires target feature 'avx512f'}}
40 free_func(); // expected-error{{'free_func' requires target feature 'avx512f'}}
41 }();
43 #endif
45 #ifdef TEST3
46 void usage(S & s) {
48 [&s] () __attribute__((target("avx512f"))) {
49 s.foo();
50 (void)(int) s;
51 s();
52 free_func();
53 }();
55 [&s] {
56 s.foo(); // expected-error {{'foo' requires target feature 'avx512f'}}
57 (void)(int) s; // expected-error {{'operator int' requires target feature 'avx512f'}}
58 s(); // expected-error {{'operator()' requires target feature 'avx512f'}}
59 free_func(); // expected-error{{'free_func' requires target feature 'avx512f'}}
60 }();
62 #endif
64 #ifdef TEST4
65 namespace PR45468 {
66 struct CtorAndDTor {
67 __attribute__((always_inline, target("avx512f"))) CtorAndDTor();
68 __attribute__((always_inline, target("avx512f"))) ~CtorAndDTor();
71 void usage() {
72 //expected-error@+1{{'CtorAndDTor' requires target feature 'avx512f'}}
73 CtorAndDTor c;
75 //expected-error@+1{{'CtorAndDTor' requires target feature 'avx512f'}}
76 CtorAndDTor c2;
77 //expected-error@+1{{'~CtorAndDTor' requires target feature 'avx512f'}}
78 c2.~CtorAndDTor();
80 // FIXME: These need to be given a line number, however there's no good way
81 // to get to the SourceLocation of anything by the time we're doing CodeGen
82 // cleanups.
83 //expected-error@*{{'~CtorAndDTor' requires target feature 'avx512f'}}
84 //expected-error@*{{'~CtorAndDTor' requires target feature 'avx512f'}}
87 #endif