1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Winvalid-noreturn %s -verify
2 
3 template<typename T>
4 void test_attributes() {
5   auto nrl = []() [[noreturn]] {}; // expected-warning{{function declared 'noreturn' should not return}}
6 }
7 
8 template void test_attributes<int>(); // expected-note{{in instantiation of function}}
9 
10 template<typename T>
11 void call_with_zero() {
12   [](T *ptr) -> T& { return *ptr; }(0);
13 }
14 
15 template void call_with_zero<int>();
16 
17 template<typename T>
18 T captures(T x, T y) {
19   auto lambda = [=, &y] () -> T {
20     T i = x;
21     return i + y;
22   };
23 
24   return lambda();
25 }
26 
27 struct X {
28   X(const X&);
29 };
30 
31 X operator+(X, X);
32 X operator-(X, X);
33 
34 template int captures(int, int);
35 template X captures(X, X);
36 
37 template<typename T>
38 int infer_result(T x, T y) {
39   auto lambda = [=](bool b) { return x + y; };
40   return lambda(true); // expected-error{{no viable conversion from 'X' to 'int'}}
41 }
42 
43 template int infer_result(int, int);
44 template int infer_result(X, X); // expected-note{{in instantiation of function template specialization 'infer_result<X>' requested here}}
45 
46