Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / unqualified-std-call.cpp
blob7cb50e378daee89c45fbe2f93d35dbf22f4755ed
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wall -std=c++11 %s -Wno-unused-value
3 namespace std {
5 template <typename T>
6 void dummy(T &&) {}
7 template <typename T>
8 T &&move(T &&x) { return x; }
9 template <typename T, typename U>
10 void move(T &&, U &&) {}
12 inline namespace __1 {
13 template <typename T>
14 T &forward(T &x) { return x; }
15 } // namespace __1
17 struct foo {};
19 } // namespace std
21 namespace global {
23 using namespace std;
25 void f() {
26 int i = 0;
27 std::move(i);
28 move(i); // expected-warning{{unqualified call to 'std::move'}}
29 (move)(i); // expected-warning{{unqualified call to 'std::move'}}
30 std::dummy(1);
31 dummy(1);
32 std::move(1, 2);
33 move(1, 2);
34 forward<int>(i); // expected-warning{{unqualified call to 'std::forward'}}
35 std::forward<int>(i);
38 template <typename T>
39 void g(T &&foo) {
40 std::move(foo);
41 move(foo); // expected-warning{{unqualified call to 'std::move}}
43 std::forward<decltype(foo)>(foo);
44 forward<decltype(foo)>(foo); // expected-warning{{unqualified call to 'std::forward}}
45 move(1, 2);
46 dummy(foo);
49 void call() {
50 g(0); //expected-note {{here}}
53 } // namespace global
55 namespace named {
57 using std::forward;
58 using std::move;
60 void f() {
61 int i = 0;
62 move(i); // expected-warning{{unqualified call to 'std::move}}
63 move(1, 2);
64 forward<int>(i); // expected-warning{{unqualified call to 'std::forward}}
67 template <typename T>
68 void g(T &&foo) {
69 move(foo); // expected-warning{{unqualified call to 'std::move}}
70 forward<decltype(foo)>(foo); // expected-warning{{unqualified call to 'std::forward}}
71 (forward<decltype(foo)>)(foo); // expected-warning{{unqualified call to 'std::forward}}
72 move(1, 2);
75 void call() {
76 g(0); //expected-note {{here}}
79 } // namespace named
81 namespace overload {
82 using namespace std;
83 template <typename T>
84 int move(T &&);
85 void f() {
86 int i = 0;
87 move(i);
89 } // namespace overload
91 namespace adl {
92 void f() {
93 move(std::foo{}); // expected-warning{{unqualified call to 'std::move}}
96 } // namespace adl
98 namespace std {
100 void f() {
101 int i = 0;
102 move(i); // expected-warning{{unqualified call to 'std::move}}
103 forward<int>(i); // expected-warning{{unqualified call to 'std::forward}}
106 } // namespace std
108 namespace test_alias {
109 namespace alias = std;
110 using namespace alias;
111 void f() {
112 int i = 0;
113 move(i); // expected-warning{{unqualified call to 'std::move}}
114 move(1, 2);
115 forward<int>(i); // expected-warning{{unqualified call to 'std::forward}}
118 } // namespace test_alias