1f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
28e8fb3be5bd78f0564444eca02b404566a5f3b5dAndy Gibbs// expected-no-diagnostics
3f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor
4f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregortemplate<typename T, typename U>
5f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregorstruct is_same {
6f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor  static const bool value = false;
7f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor};
8f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor
9f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregortemplate<typename T>
10f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregorstruct is_same<T, T> {
11f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor  static const bool value = true;
12f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor};
13f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor
14f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregorvoid f3() {
15f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor  float x, &r = x;
16f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor  int i;
17f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor  int &ir = i;
18f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor  const int &irc = i;
19f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor
20f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor  [=,&irc,&ir] {
2168932845a432d2a1dbbc57a84fd85bbb37c90487Douglas Gregor    static_assert(is_same<decltype(((r))), float const&>::value,
2268932845a432d2a1dbbc57a84fd85bbb37c90487Douglas Gregor                  "should be const float&");
23f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor    static_assert(is_same<decltype(x), float>::value, "should be float");
24f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor    static_assert(is_same<decltype((x)), const float&>::value,
25f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor                  "should be const float&");
26f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor    static_assert(is_same<decltype(r), float&>::value, "should be float&");
27f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor    static_assert(is_same<decltype(ir), int&>::value, "should be int&");
28f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor    static_assert(is_same<decltype((ir)), int&>::value, "should be int&");
29f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor    static_assert(is_same<decltype(irc), const int&>::value,
30f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor                  "should be const int&");
31f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor    static_assert(is_same<decltype((irc)), const int&>::value,
32f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor                  "should be const int&");
33f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor  }();
34f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor
35f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor  [=] {
36f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor    [=] () mutable {
37f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor      static_assert(is_same<decltype(x), float>::value, "should be float");
38999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor      static_assert(is_same<decltype((x)), float&>::value,
39999713eea940f4e087cc3ac878689c5c5c7a7225Douglas Gregor                    "should be float&");
40f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor    }();
41f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor  }();
42bd64520ca4e4d4c531637d311f8ea384c912fce8Douglas Gregor
43bd64520ca4e4d4c531637d311f8ea384c912fce8Douglas Gregor  [&i] {
44bd64520ca4e4d4c531637d311f8ea384c912fce8Douglas Gregor    static_assert(is_same<decltype((i)), int&>::value, "should be int&");
45bd64520ca4e4d4c531637d311f8ea384c912fce8Douglas Gregor  }();
46f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor}
47