| Douglas Gregor | 8962549 | 2012-02-09 08:14:43 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify |
| 2 | |
| 3 | // prvalue |
| 4 | void prvalue() { |
| Douglas Gregor | 656bc62 | 2012-02-09 08:26:42 +0000 | [diff] [blame] | 5 | auto&& x = []()->void { }; |
| 6 | auto& y = []()->void { }; // expected-error{{cannot bind to a temporary of type}} |
| Douglas Gregor | 8962549 | 2012-02-09 08:14:43 +0000 | [diff] [blame] | 7 | } |
| 8 | |
| 9 | namespace std { |
| 10 | class type_info; |
| 11 | } |
| 12 | |
| 13 | struct P { |
| 14 | virtual ~P(); |
| 15 | }; |
| 16 | |
| 17 | void unevaluated_operand(P &p, int i) { |
| Douglas Gregor | 656bc62 | 2012-02-09 08:26:42 +0000 | [diff] [blame] | 18 | int i2 = sizeof([]()->void{}()); // expected-error{{lambda expression in an unevaluated operand}} |
| 19 | const std::type_info &ti1 = typeid([&]() -> P& { return p; }()); |
| 20 | const std::type_info &ti2 = typeid([&]() -> int { return i; }()); // expected-error{{lambda expression in an unevaluated operand}} |
| Douglas Gregor | 8962549 | 2012-02-09 08:14:43 +0000 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | template<typename T> |
| 24 | struct Boom { |
| 25 | Boom(const Boom&) { |
| 26 | T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} \ |
| 27 | // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}} \ |
| 28 | // expected-error{{cannot initialize a variable of type 'double *' with an rvalue of type 'int'}} |
| 29 | } |
| 30 | void tickle() const; |
| 31 | }; |
| 32 | |
| 33 | void odr_used(P &p, Boom<int> boom_int, Boom<float> boom_float, |
| 34 | Boom<double> boom_double) { |
| 35 | const std::type_info &ti1 |
| Douglas Gregor | 656bc62 | 2012-02-09 08:26:42 +0000 | [diff] [blame] | 36 | = typeid([=,&p]() -> P& { boom_int.tickle(); return p; }()); // expected-note{{in instantiation of member function 'Boom<int>::Boom' requested here}} |
| Douglas Gregor | 8962549 | 2012-02-09 08:14:43 +0000 | [diff] [blame] | 37 | const std::type_info &ti2 |
| 38 | = typeid([=]() -> int { boom_float.tickle(); return 0; }()); // expected-error{{lambda expression in an unevaluated operand}} \ |
| Douglas Gregor | 8962549 | 2012-02-09 08:14:43 +0000 | [diff] [blame] | 39 | // expected-note{{in instantiation of member function 'Boom<float>::Boom' requested here}} |
| 40 | |
| Douglas Gregor | 656bc62 | 2012-02-09 08:26:42 +0000 | [diff] [blame] | 41 | auto foo = [=]() -> int { boom_double.tickle(); return 0; }; // expected-note{{in instantiation of member function 'Boom<double>::Boom' requested here}} |
| Douglas Gregor | 8962549 | 2012-02-09 08:14:43 +0000 | [diff] [blame] | 42 | } |