1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
269d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor
369d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregortemplate<typename T, typename U>
469d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregorstruct is_same {
569d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor  static const bool value = false;
669d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor};
769d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor
869d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregortemplate<typename T>
969d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregorstruct is_same<T, T> {
1069d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor  static const bool value = true;
1169d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor};
1269d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor#define JOIN2(X,Y) X##Y
1369d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor#define JOIN(X,Y) JOIN2(X,Y)
1469d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor#define CHECK_EQUAL_TYPES(T1, T2) \
1569d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor  int JOIN(array,__LINE__)[is_same<T1, T2>::value? 1 : -1]
1669d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor
1769d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregorint i;
1869d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregortypedef int& LRI;
1969d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregortypedef int&& RRI;
2069d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor
2169d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregortypedef LRI& r1; CHECK_EQUAL_TYPES(r1, int&);
22651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinestypedef const LRI& r2; CHECK_EQUAL_TYPES(r2, int&); // expected-warning {{'const' qualifier on reference type 'LRI' (aka 'int &') has no effect}}
23651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinestypedef const LRI&& r3; CHECK_EQUAL_TYPES(r3, int&); // expected-warning {{'const' qualifier on reference type 'LRI' (aka 'int &') has no effect}}
2469d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregor
2569d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregortypedef RRI& r4; CHECK_EQUAL_TYPES(r4, int&);
2669d831645f429d3b806d2ae220aee45ca44f8c6cDouglas Gregortypedef RRI&& r5; CHECK_EQUAL_TYPES(r5, int&&);
27