blob: 97c959454c354c651042b036b9e11e1b9b8a64c2 [file] [log] [blame]
Argyrios Kyrtzidis8e502972012-10-10 16:14:06 +00001// RUN: %clang_cc1 -std=c++11 -verify %s
2
3// rdar://12240916 stack overflow.
4namespace rdar12240916 {
5
6struct S2 {
7 S2(const S2&);
8 S2();
9};
10
11struct S { // expected-note {{not complete}}
12 S x; // expected-error {{incomplete type}}
13 S2 y;
14};
15
16S foo() {
17 S s;
18 return s;
19}
20
21struct S3; // expected-note {{forward declaration}}
22
23struct S4 {
24 S3 x; // expected-error {{incomplete type}}
25 S2 y;
26};
27
28struct S3 {
29 S4 x;
30 S2 y;
31};
32
33S4 foo2() {
34 S4 s;
35 return s;
36}
37
38}
Argyrios Kyrtzidis668bf822012-10-27 02:13:28 +000039
40// rdar://12542261 stack overflow.
41namespace rdar12542261 {
42
43template <class _Tp>
44struct check_complete
45{
46 static_assert(sizeof(_Tp) > 0, "Type must be complete.");
47};
48
49
50template<class _Rp>
51class function // expected-note 2 {{candidate}}
52{
53public:
54 template<class _Fp>
55 function(_Fp, typename check_complete<_Fp>::type* = 0); // expected-note {{candidate}}
56};
57
58void foobar()
59{
60 auto LeftCanvas = new Canvas(); // expected-error {{unknown type name}}
61 function<void()> m_OnChange = [&, LeftCanvas]() { }; // expected-error {{no viable conversion}}
62}
63
64}
Richard Smith2f36dae2012-10-28 06:18:02 +000065
66namespace b6981007 {
67 struct S {}; // expected-note 3{{candidate}}
68 void f() {
69 S s(1, 2, 3); // expected-error {{no matching}}
70 for (auto x : s) {
71 // We used to attempt to evaluate the initializer of this variable,
72 // and crash because it has an undeduced type.
Richard Smith3249fed2013-08-21 01:40:36 +000073 const int &n(x);
Richard Smith2f36dae2012-10-28 06:18:02 +000074 }
75 }
76}
Kaelyn Takata3587fff2015-03-17 23:50:12 +000077
78namespace incorrect_auto_type_deduction_for_typo {
79struct S {
80 template <typename T> S(T t) {
81 (void)sizeof(t);
82 (void)new auto(t);
83 }
84};
85
86void Foo(S);
87
88void test(int some_number) { // expected-note {{'some_number' declared here}}
89 auto x = sum_number; // expected-error {{use of undeclared identifier 'sum_number'; did you mean 'some_number'?}}
90 auto lambda = [x] {};
91 Foo(lambda);
92}
93}