[clang][Sema] Fix const FixIt placement after comparison operator member definition (#188093)
Update `InsertLoc` to use the token after the closing parenthesis when adding `const` qualification to a comparison operator Fixes #187887
This commit is contained in:
parent
8a0c070309
commit
d3224dc5da
@ -9039,7 +9039,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *FD,
|
||||
} else {
|
||||
Loc = MD->getLocation();
|
||||
if (FunctionTypeLoc Loc = MD->getFunctionTypeLoc())
|
||||
InsertLoc = Loc.getRParenLoc();
|
||||
InsertLoc = getLocForEndOfToken(Loc.getRParenLoc());
|
||||
}
|
||||
// Don't diagnose an implicit 'operator=='; we will have diagnosed the
|
||||
// corresponding defaulted 'operator<=>' already.
|
||||
|
||||
18
clang/test/FixIt/fixit-defaulted-comparison.cpp
Normal file
18
clang/test/FixIt/fixit-defaulted-comparison.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
// RUN: %clang_cc1 -verify -std=c++23 %s
|
||||
// RUN: cp %s %t
|
||||
// RUN: not %clang_cc1 -std=c++23 -x c++ -fixit %t
|
||||
// RUN: %clang_cc1 -std=c++23 -x c++ %t
|
||||
// RUN: not %clang_cc1 -std=c++23 -x c++ -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
|
||||
|
||||
namespace std {
|
||||
struct partial_ordering {};
|
||||
} // namespace std
|
||||
|
||||
struct Box {
|
||||
std::partial_ordering operator<=>(const Box& other) = default; // #ssdecl
|
||||
bool operator==(const Box& other) = default; // #eqdecl
|
||||
// expected-error@#ssdecl {{defaulted member three-way comparison operator must be const-qualified}}
|
||||
// expected-error@#eqdecl {{defaulted member equality comparison operator must be const-qualified}}
|
||||
// CHECK: fix-it:{{.*}}:{12:54-12:54}:" const"
|
||||
// CHECK: fix-it:{{.*}}:{13:36-13:36}:" const"
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user