119 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -Wall -std=c++11 %s -Wno-unused-value2 3namespace std {4 5template <typename T>6void dummy(T &&) {}7template <typename T>8T &&move(T &&x) { return x; }9template <typename T, typename U>10void move(T &&, U &&) {}11 12inline namespace __1 {13template <typename T>14T &forward(T &x) { return x; }15} // namespace __116 17struct foo {};18 19} // namespace std20 21namespace global {22 23using namespace std;24 25void 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);36}37 38template <typename T>39void g(T &&foo) {40 std::move(foo);41 move(foo); // expected-warning{{unqualified call to 'std::move}}42 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);47}48 49void call() {50 g(0); //expected-note {{here}}51}52 53} // namespace global54 55namespace named {56 57using std::forward;58using std::move;59 60void 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}}65}66 67template <typename T>68void 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);73}74 75void call() {76 g(0); //expected-note {{here}}77}78 79} // namespace named80 81namespace overload {82using namespace std;83template <typename T>84int move(T &&);85void f() {86 int i = 0;87 move(i);88}89} // namespace overload90 91namespace adl {92void f() {93 move(std::foo{}); // expected-warning{{unqualified call to 'std::move}}94}95 96} // namespace adl97 98namespace std {99 100void 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}}104}105 106} // namespace std107 108namespace test_alias {109namespace alias = std;110using namespace alias;111void 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}}116}117 118} // namespace test_alias119