1c24e6dd3SEric Fiselier //===----------------------------------------------------------------------===//
2c24e6dd3SEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6c24e6dd3SEric Fiselier //
7c24e6dd3SEric Fiselier //===----------------------------------------------------------------------===//
8c24e6dd3SEric Fiselier 
9c24e6dd3SEric Fiselier // test forward
10c24e6dd3SEric Fiselier 
11c24e6dd3SEric Fiselier #include <utility>
12c24e6dd3SEric Fiselier 
13c24e6dd3SEric Fiselier #include "test_macros.h"
14c24e6dd3SEric Fiselier 
15c24e6dd3SEric Fiselier struct A
16c24e6dd3SEric Fiselier {
17c24e6dd3SEric Fiselier };
18c24e6dd3SEric Fiselier 
source()19c24e6dd3SEric Fiselier A source() {return A();}
csource()20c24e6dd3SEric Fiselier const A csource() {return A();}
21c24e6dd3SEric Fiselier 
main(int,char **)222df59c50SJF Bastien int main(int, char**)
23c24e6dd3SEric Fiselier {
24c24e6dd3SEric Fiselier     {
2572315d02SRichard Smith         (void)std::forward<A&>(source());  // expected-note {{requested here}}
26*76476efdSMuhammad Usman Shahid         // expected-error-re@*:* 1 {{{{(static_assert|static assertion)}} failed{{.*}}cannot forward an rvalue as an lvalue}}
27c24e6dd3SEric Fiselier     }
28c24e6dd3SEric Fiselier     {
29c24e6dd3SEric Fiselier         const A ca = A();
30c24e6dd3SEric Fiselier         std::forward<A&>(ca); // expected-error {{no matching function for call to 'forward'}}
31c24e6dd3SEric Fiselier     }
32c24e6dd3SEric Fiselier     {
33c24e6dd3SEric Fiselier         std::forward<A&>(csource());  // expected-error {{no matching function for call to 'forward'}}
34c24e6dd3SEric Fiselier     }
35c24e6dd3SEric Fiselier     {
36c24e6dd3SEric Fiselier         const A ca = A();
37c24e6dd3SEric Fiselier         std::forward<A>(ca); // expected-error {{no matching function for call to 'forward'}}
38c24e6dd3SEric Fiselier     }
39c24e6dd3SEric Fiselier     {
40c24e6dd3SEric Fiselier         std::forward<A>(csource()); // expected-error {{no matching function for call to 'forward'}}
41c24e6dd3SEric Fiselier     }
42c24e6dd3SEric Fiselier     {
43c24e6dd3SEric Fiselier         A a;
44c24e6dd3SEric Fiselier         std::forward(a); // expected-error {{no matching function for call to 'forward'}}
45c24e6dd3SEric Fiselier     }
462df59c50SJF Bastien 
472df59c50SJF Bastien   return 0;
48c24e6dd3SEric Fiselier }
49