This adds a diagnostic when an unqualified call is resolved to std::move or std::forward. This follows some C++ committee discussions where some people where concerns that this might be an usual anti pattern particularly britle worth warning about - both because move is a common name and because these functions accept any values. This warns inconditionnally of whether the current context is in std:: or not, as implementations probably want to always qualify these calls too, to avoid triggering adl accidentally. Differential Revision: https://reviews.llvm.org/D119670
24 lines
529 B
C++
24 lines
529 B
C++
// RUN: %clang_cc1 -verify -std=c++20 -Wall %s
|
|
// RUN: cp %s %t
|
|
// RUN: %clang_cc1 -x c++ -std=c++20 -fixit %t
|
|
// RUN: %clang_cc1 -Wall -Werror -x c++ -std=c++20 %t
|
|
// RUN: cat %t | FileCheck %s
|
|
|
|
namespace std {
|
|
|
|
void move(auto &&a) {}
|
|
|
|
void forward(auto &a) {}
|
|
|
|
} // namespace std
|
|
|
|
using namespace std;
|
|
|
|
void f() {
|
|
int i = 0;
|
|
move(i); // expected-warning {{unqualified call to std::move}}
|
|
// CHECK: {{^}} std::
|
|
forward(i); // expected-warning {{unqualified call to std::forward}}
|
|
// CHECK: {{^}} std::
|
|
}
|