1*87a03625SMalcolm Parsons // RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify
2c6e68daaSAndy Gibbs // expected-no-diagnostics
381495f34SDouglas Gregor 
481495f34SDouglas Gregor template<typename T, typename U>
581495f34SDouglas Gregor struct is_same {
681495f34SDouglas Gregor   static const bool value = false;
781495f34SDouglas Gregor };
881495f34SDouglas Gregor 
981495f34SDouglas Gregor template<typename T>
1081495f34SDouglas Gregor struct is_same<T, T> {
1181495f34SDouglas Gregor   static const bool value = true;
1281495f34SDouglas Gregor };
1381495f34SDouglas Gregor 
f3()1481495f34SDouglas Gregor void f3() {
1581495f34SDouglas Gregor   float x, &r = x;
1681495f34SDouglas Gregor   int i;
1781495f34SDouglas Gregor   int &ir = i;
1881495f34SDouglas Gregor   const int &irc = i;
1981495f34SDouglas Gregor 
2081495f34SDouglas Gregor   [=,&irc,&ir] {
21812d8f63SDouglas Gregor     static_assert(is_same<decltype(((r))), float const&>::value,
22812d8f63SDouglas Gregor                   "should be const float&");
2381495f34SDouglas Gregor     static_assert(is_same<decltype(x), float>::value, "should be float");
2481495f34SDouglas Gregor     static_assert(is_same<decltype((x)), const float&>::value,
2581495f34SDouglas Gregor                   "should be const float&");
2681495f34SDouglas Gregor     static_assert(is_same<decltype(r), float&>::value, "should be float&");
2781495f34SDouglas Gregor     static_assert(is_same<decltype(ir), int&>::value, "should be int&");
2881495f34SDouglas Gregor     static_assert(is_same<decltype((ir)), int&>::value, "should be int&");
2981495f34SDouglas Gregor     static_assert(is_same<decltype(irc), const int&>::value,
3081495f34SDouglas Gregor                   "should be const int&");
3181495f34SDouglas Gregor     static_assert(is_same<decltype((irc)), const int&>::value,
3281495f34SDouglas Gregor                   "should be const int&");
3381495f34SDouglas Gregor   }();
3481495f34SDouglas Gregor 
3581495f34SDouglas Gregor   [=] {
3681495f34SDouglas Gregor     [=] () mutable {
3781495f34SDouglas Gregor       static_assert(is_same<decltype(x), float>::value, "should be float");
38fdf598eaSDouglas Gregor       static_assert(is_same<decltype((x)), float&>::value,
39fdf598eaSDouglas Gregor                     "should be float&");
4081495f34SDouglas Gregor     }();
4181495f34SDouglas Gregor   }();
427ae3c75dSDouglas Gregor 
437ae3c75dSDouglas Gregor   [&i] {
447ae3c75dSDouglas Gregor     static_assert(is_same<decltype((i)), int&>::value, "should be int&");
457ae3c75dSDouglas Gregor   }();
4681495f34SDouglas Gregor }
47