Debian Codegraph @

gcc/testsuite/g++.dg/opt/pr96780.C

raw
1 // PR c++/96780
2 // Verify calls to std::move/forward are folded away by the frontend.
3 // { dg-do compile { target c++11 } }
4 // { dg-additional-options "-ffold-simple-inlines -fdump-tree-gimple" }
5
6 #include <utility>
7
8 struct A;
9
10 extern A& a;
11 extern const A& ca;
12
13 void f() {
14 auto&& x1 = std::move(a);
15 auto&& x2 = std::forward<A>(a);
16 auto&& x3 = std::forward<A&>(a);
17
18 auto&& x4 = std::move(ca);
19 auto&& x5 = std::forward<const A>(ca);
20 auto&& x6 = std::forward<const A&>(ca);
21
22 auto x7 = std::addressof(a);
23 auto x8 = std::addressof(ca);
24 #if __GLIBCXX__
25 auto x9 = std::__addressof(a);
26 auto x10 = std::__addressof(ca);
27 #endif
28 #if __cpp_lib_as_const
29 auto&& x11 = std::as_const(a);
30 auto&& x12 = std::as_const(ca);
31 #endif
32 #if __cpp_lib_forward_like
33 auto&& x13 = std::forward_like<int&&>(a);
34 auto&& x14 = std::forward_like<int&&>(ca);
35 #endif
36 }
37
38 // { dg-final { scan-tree-dump-not "= std::move" "gimple" } }
39 // { dg-final { scan-tree-dump-not "= std::forward" "gimple" } }
40 // { dg-final { scan-tree-dump-not "= std::addressof" "gimple" } }
41 // { dg-final { scan-tree-dump-not "= std::__addressof" "gimple" } }
42 // { dg-final { scan-tree-dump-not "= std::as_const" "gimple" } }
43 // { dg-final { scan-tree-dump-not "= std::forward_like" "gimple" } }