[lld][WebAssembly] Reinstate mistakenly disabled test. NFC
[llvm-project.git] / clang / test / SemaCXX / cxx2b-p2266-disable-with-msvc-compat.cpp
blob17247c4473178f03f72296e49d4088509b1b2afa
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"
14 #endif
16 struct nocopy {
17 nocopy(nocopy &&);
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; }
24 namespace {
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; }
28 } // namespace
30 namespace foo {
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}}
33 namespace std {
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; }
37 } // namespace std
38 } // namespace foo
40 namespace std {
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; }
46 namespace {
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; }
50 } // namespace
52 namespace foo {
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; }
56 } // namespace foo
58 } // namespace std
60 #include __FILE__
62 #define SYSTEM
63 #include __FILE__
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; }
71 namespace {
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; }
75 } // namespace
77 namespace foo {
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; }
81 namespace std {
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; }
85 } // namespace std
86 } // namespace foo
88 namespace std {
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; }
94 namespace {
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; }
98 } // namespace
100 namespace foo {
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; }
104 } // namespace foo
106 } // namespace std
108 #else
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; }
116 namespace {
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; }
120 } // namespace
122 namespace foo {
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; }
126 namespace std {
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; }
130 } // namespace std
131 } // namespace foo
133 namespace std {
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; }
139 namespace {
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; }
143 } // namespace
145 namespace foo {
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; }
149 } // namespace foo
151 } // namespace std
153 #endif