[X86] Move getGFNICtrlMask before CTLZ/CTTZ lowering. NFC.
[llvm-project.git] / clang / test / SemaCXX / cxx11-crashes.cpp
blob11bc42315421d62d202c06d340190be0c2bf3368
1 // RUN: %clang_cc1 -std=c++11 -verify %s -Wno-deprecated-builtins
3 namespace rdar12240916 {
5 struct S2 {
6 S2(const S2&);
7 S2();
8 };
10 struct S { // expected-note {{not complete}}
11 S x; // expected-error {{incomplete type}}
12 S2 y;
15 S foo() {
16 S s;
17 return s;
20 struct S3; // expected-note {{forward declaration}}
22 struct S4 {
23 S3 x; // expected-error {{incomplete type}}
24 S2 y;
27 struct S3 {
28 S4 x;
29 S2 y;
32 S4 foo2() {
33 S4 s;
34 return s;
39 namespace rdar12542261 {
41 template <class _Tp>
42 struct check_complete
44 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
48 template<class _Rp>
49 class function // expected-note 2 {{candidate}}
51 public:
52 template<class _Fp>
53 function(_Fp, typename check_complete<_Fp>::type* = 0); // expected-note {{candidate}}
56 void foobar()
58 auto LeftCanvas = new Canvas(); // expected-error {{unknown type name}}
59 function<void()> m_OnChange = [&, LeftCanvas]() { }; // expected-error {{no viable conversion}}
64 namespace b6981007 {
65 struct S {}; // expected-note 3{{candidate}}
66 void f() {
67 S s(1, 2, 3); // expected-error {{no matching}}
68 for (auto x : s) {
69 // We used to attempt to evaluate the initializer of this variable,
70 // and crash because it has an undeduced type.
71 const int &n(x);
72 constexpr int k = sizeof(x);
77 namespace incorrect_auto_type_deduction_for_typo {
78 struct S {
79 template <typename T> S(T t) {
80 (void)sizeof(t);
81 (void)new auto(t);
85 void Foo(S);
87 void test(int some_number) { // expected-note {{'some_number' declared here}}
88 auto x = sum_number; // expected-error {{use of undeclared identifier 'sum_number'; did you mean 'some_number'?}}
89 auto lambda = [x] {};
90 Foo(lambda);
94 namespace pr29091 {
95 struct X{ X(const X &x); };
96 struct Y: X { using X::X; };
97 bool foo() { return __has_nothrow_constructor(Y); }
98 bool bar() { return __has_nothrow_copy(Y); }
100 struct A { template <typename T> A(); };
101 struct B : A { using A::A; };
102 bool baz() { return __has_nothrow_constructor(B); }
103 bool qux() { return __has_nothrow_copy(B); }
106 namespace undeduced_field {
107 template<class T>
108 struct Foo {
109 typedef T type;
112 struct Bar {
113 Bar();
114 // The missing expression makes A undeduced.
115 static constexpr auto A = ; // expected-error {{expected expression}}
116 // expected-error@-1 {{declaration of variable 'A' with deduced type 'const auto' requires an initializer}}
118 Foo<decltype(A)>::type B; // The type of B is also undeduced (wrapped in Elaborated).
121 // This used to crash when trying to get the layout of B.
122 Bar x;