1 // RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=cxx2b,new %s
2 // RUN: %clang_cc1 -std=c++2b -fsyntax-only -fms-compatibility -verify=cxx2b,old %s
3 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=cxx20,old %s
5 // FIXME: This is a test for a temporary workaround where we disable simpler implicit moves
6 // in the STL when compiling with -fms-compatibility, because of issues with the
7 // implementation there.
8 // Feel free to delete this file when the workaround is not needed anymore.
10 #if __INCLUDE_LEVEL__ == 0
12 #if __cpluscplus > 202002L && __cpp_implicit_move < 202011L
13 #error "__cpp_implicit_move not defined correctly"
20 int &&mt1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
21 int &mt2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
22 nocopy
mt3(nocopy x
) { return x
; }
25 int &&mt1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
26 int &mt2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
27 nocopy
mt3(nocopy x
) { return x
; }
31 int &&mt1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
32 int &mt2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
34 int &&mt1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
35 int &mt2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
36 nocopy
mt3(nocopy x
) { return x
; }
42 int &&mt1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
43 int &mt2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
44 nocopy
mt3(nocopy x
) { return x
; }
47 int &&mt1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
48 int &mt2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
49 nocopy
mt3(nocopy x
) { return x
; }
53 int &&mt1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
54 int &mt2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
55 nocopy
mt3(nocopy x
) { return x
; }
65 #elif !defined(SYSTEM)
67 int &&ut1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
68 int &ut2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
69 nocopy
ut3(nocopy x
) { return x
; }
72 int &&ut1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
73 int &ut2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
74 nocopy
ut3(nocopy x
) { return x
; }
78 int &&ut1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
79 int &ut2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
80 nocopy
ut3(nocopy x
) { return x
; }
82 int &&ut1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
83 int &ut2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
84 nocopy
ut3(nocopy x
) { return x
; }
90 int &&ut1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
91 int &ut2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
92 nocopy
ut3(nocopy x
) { return x
; }
95 int &&ut1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
96 int &ut2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
97 nocopy
ut3(nocopy x
) { return x
; }
101 int &&ut1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
102 int &ut2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
103 nocopy
ut3(nocopy x
) { return x
; }
110 #pragma GCC system_header
112 int &&st1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
113 int &st2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
114 nocopy
st3(nocopy x
) { return x
; }
117 int &&st1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
118 int &st2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
119 nocopy
st3(nocopy x
) { return x
; }
123 int &&st1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
124 int &st2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
125 nocopy
st3(nocopy x
) { return x
; }
127 int &&st1(int &&x
) { return x
; } // cxx20-error {{cannot bind to lvalue}}
128 int &st2(int &&x
) { return x
; } // cxx2b-error {{cannot bind to a temporary}}
129 nocopy
st3(nocopy x
) { return x
; }
135 int &&st1(int &&x
) { return x
; } // old-error {{cannot bind to lvalue}}
136 int &st2(int &&x
) { return x
; } // new-error {{cannot bind to a temporary}}
137 nocopy
st3(nocopy x
) { return x
; }
140 int &&st1(int &&x
) { return x
; } // old-error {{cannot bind to lvalue}}
141 int &st2(int &&x
) { return x
; } // new-error {{cannot bind to a temporary}}
142 nocopy
st3(nocopy x
) { return x
; }
146 int &&st1(int &&x
) { return x
; } // old-error {{cannot bind to lvalue}}
147 int &st2(int &&x
) { return x
; } // new-error {{cannot bind to a temporary}}
148 nocopy
st3(nocopy x
) { return x
; }