[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / crash-GH67914.cpp
blobfbaeac636c0db1c451f381f9477d316391a4ab35
1 // RUN: %clang_cc1 -verify -std=c++98 %s
2 // RUN: %clang_cc1 -verify -std=c++11 %s
3 // RUN: %clang_cc1 -verify -std=c++14 %s
4 // RUN: %clang_cc1 -verify -std=c++17 %s
5 // RUN: %clang_cc1 -verify -std=c++20 %s
6 // RUN: %clang_cc1 -verify -std=c++23 %s
7 // RUN: %clang_cc1 -verify -std=c++2c %s
9 // https://github.com/llvm/llvm-project/issues/67914
11 template < typename, int >
12 struct Mask;
14 template < int, class >
15 struct conditional {
16 using type = Mask< int, 16 >; // expected-warning 0+ {{}}
19 template < class _Then >
20 struct conditional< 0, _Then > {
21 using type = _Then; // expected-warning 0+ {{}}
24 template < int _Bp, class, class _Then >
25 using conditional_t = typename conditional< _Bp, _Then >::type; // expected-warning 0+ {{}}
27 template < typename, int >
28 struct Array;
30 template < typename, int, bool, typename >
31 struct StaticArrayImpl;
33 template < typename Value_, int Size_ >
34 struct Mask : StaticArrayImpl< Value_, Size_, 1, Mask< Value_, Size_ > > { // expected-note 0+ {{}}
35 template < typename T1 >
36 Mask(T1) {} // expected-note 0+ {{}}
39 template < typename T >
40 void load(typename T::MaskType mask) {
41 T::load_(mask); // expected-note 0+ {{}}
44 template < typename Value_, int IsMask_, typename Derived_ >
45 struct StaticArrayImpl< Value_, 32, IsMask_, Derived_ > {
46 using Array1 = conditional_t< IsMask_, void, Array< Value_, 16 > >; // expected-warning 0+ {{}}
48 template < typename Mask >
49 static Derived_ load_(Mask mask) {
50 return Derived_{load< Array1 >(mask.a1), Mask{}}; // expected-error 0+ {{}}
53 Array1 a1;
56 template < typename Derived_ >
57 struct KMaskBase;
59 template < typename Derived_ >
60 struct StaticArrayImpl< float, 16, 0, Derived_ > {
61 template < typename Mask >
62 static Derived_ load_(Mask mask);
65 template < typename Derived_ >
66 struct StaticArrayImpl< float, 16, 1, Mask< float, 16 > > : KMaskBase< Derived_ > {}; // expected-error 0+ {{}}
68 template < typename Derived_ >
69 struct StaticArrayImpl< int, 16, 1, Derived_ > {};
71 template < typename Value_, int Size_ >
72 struct Array : StaticArrayImpl< Value_, Size_, 0, Array< Value_, Size_ > > {
73 using MaskType = Mask< Value_, Size_ >; // expected-warning 0+ {{}}
76 void test11_load_masked() {
77 load< Array< float, 32 > >{} == 0; // expected-error 0+ {{}} expected-warning 0+ {{}} expected-note 0+ {{}}