p18.cpp revision f8af98286022f72157d84951b48fde5fb369ab29
1// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
2
3template<typename T, typename U>
4struct is_same {
5  static const bool value = false;
6};
7
8template<typename T>
9struct is_same<T, T> {
10  static const bool value = true;
11};
12
13void f3() {
14  float x, &r = x;
15  int i;
16  int &ir = i;
17  const int &irc = i;
18
19  [=,&irc,&ir] {
20    static_assert(is_same<decltype(x), float>::value, "should be float");
21    static_assert(is_same<decltype((x)), const float&>::value,
22                  "should be const float&");
23    static_assert(is_same<decltype(r), float&>::value, "should be float&");
24    static_assert(is_same<decltype(((r))), float const&>::value,
25                  "should be const float&");
26    static_assert(is_same<decltype(ir), int&>::value, "should be int&");
27    static_assert(is_same<decltype((ir)), int&>::value, "should be int&");
28    static_assert(is_same<decltype(irc), const int&>::value,
29                  "should be const int&");
30    static_assert(is_same<decltype((irc)), const int&>::value,
31                  "should be const int&");
32  }();
33
34  [=] {
35    [=] () mutable {
36      static_assert(is_same<decltype(x), float>::value, "should be float");
37      static_assert(is_same<decltype((x)), const float&>::value,
38                    "should be const float&");
39    }();
40  }();
41}
42